Hi,
I'm running into this error when I try to start certain levels on my game.
NullReferenceException: Object reference not set to an instance of an object
AC.MenuElement.CreateHoverSoundHandler (UnityEngine.UI.Selectable selectable, AC.Menu _menu, System.Int32 _slotIndex) (at Assets/Plugins/AdventureCreator/Scripts/Menu/Menu classes/MenuElement.cs:247)
AC.MenuInput.LoadUnityUI (AC.Menu _menu, UnityEngine.Canvas canvas, System.Boolean addEventListeners) (at Assets/Plugins/AdventureCreator/Scripts/Menu/Menu classes/MenuInput.cs:130)
AC.Menu.LoadUnityUI (System.Boolean addEventListeners) (at Assets/Plugins/AdventureCreator/Scripts/Menu/Menu classes/Menu.cs:409)
AC.PlayerMenus.RebuildMenus (AC.MenuManager menuManager) (at Assets/Plugins/AdventureCreator/Scripts/Controls/PlayerMenus.cs:165)
AC.PlayerMenus.OnInitPersistentEngine () (at Assets/Plugins/AdventureCreator/Scripts/Controls/PlayerMenus.cs:87)
AC.StateHandler.Initialise (System.Boolean rebuildMenus) (at Assets/Plugins/AdventureCreator/Scripts/Game engine/StateHandler.cs:122)
AC.KickStarter.SetPersistentEngine () (at Assets/Plugins/AdventureCreator/Scripts/Game engine/KickStarter.cs:182)
AC.KickStarter.Initialise () (at Assets/Plugins/AdventureCreator/Scripts/Game engine/KickStarter.cs:1138)
AC.MultiSceneChecker.Awake () (at Assets/Plugins/AdventureCreator/Scripts/Game engine/MultiSceneChecker.cs:43)
I'm not using any hover audio for any of my menus and the error doesn't seem to point to any menu in particular which has me stuck on how to get rid of the error. The main difference I see in the scenes that throw this error and the one that doesn't is I have different UI menus living in the scene and they are connected to AC's Menu Manager using "Unity UI in Scene" as the Source. I still get the error when turning off the scene based UI menus before starting the scenes.
I can comment out the block of code that causes the error in the MenuElement.cs script (line 247-252) to get my game running properly but I think it would be great to resolve this error without having to do that. If anyone has any tips on what could be causing the error or how to better debug to find the issue it would be much appreciated!
I just updated my project from Unity 2018.4.30, AC version 1.70.4 to Unity 2020.3.25, AC version 1.74.5. I did a complete reinstall of AC deleting the old download package and AdventureCreator project folder then re-import, deleted my Library folder for a re-import as well.
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
This looks to be caused by an Input menu element losing its connection to a Unity Input component - or a TMP_InputField component if you're using Text Mesh Pro.
We can get details about which menu and element are involved by pasting the following just above the offending line (MenuElement.cs:247):
That should produce a warning in the Console message - is the menu and element it refers to linked to the correct associated UI component?
Thanks, Chris! Got it working by making the menu's source "Unity UI Prefab" instead of "Unity UI in Scene". Another question, is there a way to suppress the following AC warning when having a menu set to "Unity UI in Scene":
I have a few scene based UI menus living in one scene and not meant to be in other scenes and this warning creates a fair bit of noise in the console when playing in those other scenes.
Thanks again!
Can you share the warning messages in full - stacktrace included?
For a typical menu that displays this warning, what is it's "Appear type" set to, and is it unlocked?
Sure, Chris. The "Appear type" is set to Manual and the menu is unlocked. Here's the stacktrace:
Thanks, I'll look into it and give it some thought.