Hi, I just found this script KickStarter.player.portraitIcon.Reset ();
gives the following error message in both v1.71.0 & 1.71.1. Is the API changed or would that be a bug? I am using the script in a MonoBehaviour script that is attached to the Inventory Menu UI.
NullReferenceException: Object reference not set to an instance of an object
InventoryScript.OnEnable () (at Assets/Ricky/Scripts/UI/Inventory/InventoryScript.cs:98)
UnityEngine.Object:Instantiate(Canvas)
AC.Menu:LocateLocalCanvas() (at Assets/Plugins/AdventureCreator/Scripts/Menu/Menu classes/Menu.cs:3022)
AC.Menu:LoadUnityUI() (at Assets/Plugins/AdventureCreator/Scripts/Menu/Menu classes/Menu.cs:372)
AC.PlayerMenus:RebuildMenus(MenuManager) (at Assets/Plugins/AdventureCreator/Scripts/Controls/PlayerMenus.cs:149)
AC.PlayerMenus:OnInitPersistentEngine() (at Assets/Plugins/AdventureCreator/Scripts/Controls/PlayerMenus.cs:87)
AC.StateHandler:Initialise(Boolean) (at Assets/Plugins/AdventureCreator/Scripts/Game engine/StateHandler.cs:99)
AC.KickStarter:SetPersistentEngine() (at Assets/Plugins/AdventureCreator/Scripts/Game engine/KickStarter.cs:157)
AC.KickStarter:Initialise() (at Assets/Plugins/AdventureCreator/Scripts/Game engine/KickStarter.cs:1096)
AC.MultiSceneChecker:Awake() (at Assets/Plugins/AdventureCreator/Scripts/Game engine/MultiSceneChecker.cs:44)
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
Menus are spawned in before the Player, so it's "KickStarter.player" that is null if you're calling this in OnEnable.
Try moving this call to the Start function, or wrapping a null-check around it, i.e.:
Thanks! It's fixed!