Forum rules - please read before posting.

"The script class needs to derive from ScriptableObject"

I've successfully added buttons to AC menus approximately a bazillion times, but Unity is suddenly deciding to take exception, and I'm getting these errors when I try to add button elements to AC menus. The error only flags on buttons; I could add a label just fine.

NullReferenceException: Object reference not set to an instance of an object
AC.MenuManager.AddElement (System.String className, AC.Menu _menu) (at Assets/AdventureCreator/Scripts/Managers/MenuManager.cs:593)
AC.MenuManager.CreateElementsGUI (AC.Menu _menu) (at Assets/AdventureCreator/Scripts/Managers/MenuManager.cs:485)
AC.MenuManager.ShowGUI () (at Assets/AdventureCreator/Scripts/Managers/MenuManager.cs:187)
AC.AdventureCreator.OnGUI () (at Assets/AdventureCreator/Scripts/Managers/Editor/AdventureCreator.cs:320)

Instance of MenuButton couldn't be created. The the script class needs to derive from ScriptableObject.
UnityEngine.ScriptableObject:CreateInstance (string)
AC.MenuManager:AddElement (string,AC.Menu) (at Assets/AdventureCreator/Scripts/Managers/MenuManager.cs:592)
AC.MenuManager:CreateElementsGUI (AC.Menu) (at Assets/AdventureCreator/Scripts/Managers/MenuManager.cs:485)
AC.MenuManager:ShowGUI () (at Assets/AdventureCreator/Scripts/Managers/MenuManager.cs:187)
AC.AdventureCreator:OnGUI () (at Assets/AdventureCreator/Scripts/Managers/Editor/AdventureCreator.cs:320)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

I'm running Unity 2020.3.13f1 (I updated specifically to see if that would alleviate things)
and Adventure Creator v1.73.8

I've tried restarting Unity and my computer a few times to no avail. Any advice would be highly welcome!


  • It could be that you have another script or class in your project that shares the same name, "MenuButton".

    Try this potential fix: open up MenuManager.cs, and replace the line around 592:

    MenuElement newElement = (MenuElement) CreateInstance (className);


    MenuElement newElement = (MenuElement) CreateInstance ("AC." + className);

    Does that resolve it?

  • That was it precisely. Per your suggestion, I see now that another recently-added plugin included the file MenuButton.cs, and that created the conflict.

    Everything's humming along now; thank you so much!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.