Issue Regarding Custom UI

Posted: 03 Jul 2021 23:57
by tr5414

I'm trying to implement a simple bar as a Custom U.I. I've put it into my U.I resources, but everytime I start the game I get a NullReferenceException and the game wont load after that. Not Sure why this is happening. Any help would be appreciated. Here is a the complete error:

NullReferenceException: Object reference not set to an instance of an object
Naninovel.UI.CustomUI.OnEnable () (at Assets/Naninovel/Runtime/UI/CustomUI.cs:130)
UnityEngine.Object:Instantiate(GameObject)
Naninovel.Engine:Instantiate(GameObject, String, Nullable1, Transform) (at Assets/Naninovel/Runtime/Engine/Engine.cs:293)
Naninovel.UIManager:InstantiatePrefab(GameObject, String) (at Assets/Naninovel/Runtime/UI/UIManager.cs:191)
Naninovel.<InstantiateUIsAsync>d__38:MoveNext() (at Assets/Naninovel/Runtime/UI/UIManager.cs:246)
UniRx.Async.CompilerServices.AsyncUniTaskMethodBuilder:Start(<InstantiateUIsAsync>d__38&) (at Assets/Naninovel/Runtime/Common/Async/UniTask/CompilerServices/AsyncUniTaskMethodBuilder.cs:133)
Naninovel.UIManager:InstantiateUIsAsync()
Naninovel.<InitializeAsync>d__37:MoveNext() (at Assets/Naninovel/Runtime/Engine/Engine.cs:137)
UniRx.Async.CompilerServices.MoveNextRunner
1:Run() (at Assets/Naninovel/Runtime/Common/Async/UniTask/CompilerServices/MoveNextRunner.cs:20)
UniRx.Async.UniTaskCompletionSource:TryInvokeContinuation() (at Assets/Naninovel/Runtime/Common/Async/UniTask/UniTaskCompletionSource.cs:171)
UniRx.Async.UniTaskCompletionSource:TrySetResult() (at Assets/Naninovel/Runtime/Common/Async/UniTask/UniTaskCompletionSource.cs:189)
UniRx.Async.CompilerServices.AsyncUniTaskMethodBuilder:SetResult() (at Assets/Naninovel/Runtime/Common/Async/UniTask/CompilerServices/AsyncUniTaskMethodBuilder.cs:81)
Naninovel.<PerformPostEngineInitializationTasks>d__92:MoveNext() (at Assets/Naninovel/Runtime/State/StateManager.cs:358)
UniRx.Async.CompilerServices.MoveNextRunner1:Run() (at Assets/Naninovel/Runtime/Common/Async/UniTask/CompilerServices/MoveNextRunner.cs:20)
UniRx.Async.UniTaskCompletionSource:TryInvokeContinuation() (at Assets/Naninovel/Runtime/Common/Async/UniTask/UniTaskCompletionSource.cs:171)
UniRx.Async.UniTaskCompletionSource:TrySetResult() (at Assets/Naninovel/Runtime/Common/Async/UniTask/UniTaskCompletionSource.cs:189)
UniRx.Async.CompilerServices.AsyncUniTaskMethodBuilder:SetResult() (at Assets/Naninovel/Runtime/Common/Async/UniTask/CompilerServices/AsyncUniTaskMethodBuilder.cs:81)
Naninovel.<<PerformPostEngineInitializationTasks>g__LoadGlobalAsync|92_1>d:MoveNext() (at Assets/Naninovel/Runtime/State/StateManager.cs:348)
UniRx.Async.CompilerServices.MoveNextRunner
1:Run() (at Assets/Naninovel/Runtime/Common/Async/UniTask/CompilerServices/MoveNextRunner.cs:20)
UniRx.Async.UniTaskCompletionSource1:TryInvokeContinuation() (at Assets/Naninovel/Runtime/Common/Async/UniTask/UniTaskCompletionSource.cs:342)
UniRx.Async.UniTaskCompletionSource
1:TrySetResult(GlobalStateMap) (at Assets/Naninovel/Runtime/Common/Async/UniTask/UniTaskCompletionSource.cs:361)
UniRx.Async.CompilerServices.AsyncUniTaskMethodBuilder1:SetResult(GlobalStateMap) (at Assets/Naninovel/Runtime/Common/Async/UniTask/CompilerServices/AsyncUniTaskMethodBuilder.cs:229)
Naninovel.<LoadOrDefaultAsync>d__13:MoveNext() (at Assets/Naninovel/Runtime/Common/SaveSlotManager/IOSaveSlotManager.cs:104)
UniRx.Async.CompilerServices.MoveNextRunner
1:Run() (at Assets/Naninovel/Runtime/Common/Async/UniTask/CompilerServices/MoveNextRunner.cs:20)
UniRx.Async.UniTaskCompletionSource1:TryInvokeContinuation() (at Assets/Naninovel/Runtime/Common/Async/UniTask/UniTaskCompletionSource.cs:342)
UniRx.Async.UniTaskCompletionSource
1:TrySetResult(GlobalStateMap) (at Assets/Naninovel/Runtime/Common/Async/UniTask/UniTaskCompletionSource.cs:361)
UniRx.Async.CompilerServices.AsyncUniTaskMethodBuilder1:SetResult(GlobalStateMap) (at Assets/Naninovel/Runtime/Common/Async/UniTask/CompilerServices/AsyncUniTaskMethodBuilder.cs:229)
Naninovel.<LoadAsync>d__12:MoveNext() (at Assets/Naninovel/Runtime/Common/SaveSlotManager/IOSaveSlotManager.cs:96)
UniRx.Async.CompilerServices.MoveNextRunner
1:Run() (at Assets/Naninovel/Runtime/Common/Async/UniTask/CompilerServices/MoveNextRunner.cs:20)
UniRx.Async.UniTaskCompletionSource1:TryInvokeContinuation() (at Assets/Naninovel/Runtime/Common/Async/UniTask/UniTaskCompletionSource.cs:342)
UniRx.Async.UniTaskCompletionSource
1:TrySetResult(GlobalStateMap) (at Assets/Naninovel/Runtime/Common/Async/UniTask/UniTaskCompletionSource.cs:361)
UniRx.Async.CompilerServices.AsyncUniTaskMethodBuilder1:SetResult(GlobalStateMap) (at Assets/Naninovel/Runtime/Common/Async/UniTask/CompilerServices/AsyncUniTaskMethodBuilder.cs:229)
Naninovel.<DeserializeDataAsync>d__20:MoveNext() (at Assets/Naninovel/Runtime/Common/SaveSlotManager/IOSaveSlotManager.cs:158)
UniRx.Async.CompilerServices.MoveNextRunner
1:Run() (at Assets/Naninovel/Runtime/Common/Async/UniTask/CompilerServices/MoveNextRunner.cs:20)
UniRx.Async.UniTaskCompletionSource1:TryInvokeContinuation() (at Assets/Naninovel/Runtime/Common/Async/UniTask/UniTaskCompletionSource.cs:342)
UniRx.Async.UniTaskCompletionSource
1:TrySetResult(String) (at Assets/Naninovel/Runtime/Common/Async/UniTask/UniTaskCompletionSource.cs:361)
UniRx.Async.CompilerServices.AsyncUniTaskMethodBuilder1:SetResult(String) (at Assets/Naninovel/Runtime/Common/Async/UniTask/CompilerServices/AsyncUniTaskMethodBuilder.cs:229)
Naninovel.<UnzipStringAsync>d__28:MoveNext() (at Assets/Naninovel/Runtime/Common/Utilities/StringUtils.cs:395)
UniRx.Async.CompilerServices.MoveNextRunner
1:Run() (at Assets/Naninovel/Runtime/Common/Async/UniTask/CompilerServices/MoveNextRunner.cs:20)
UnityEngine.UnitySynchronizationContext:ExecuteTasks()


Re: Issue Regarding Custom UI

Posted: 04 Jul 2021 10:06
by Elringus

You're probably spawning the gameobject with the custom UI before the engine is initialized. Make sure you don't manually add it on scene or as part of other prefabs (Naninovel will spawn it itself). Also, in case you're modifying engine initialization UI, don't use custom UI there, use plain uGUI.


Re: Issue Regarding Custom UI

Posted: 06 Jul 2021 23:54
by tr5414

Im not spawning the bar object in the scene beforehand, so thats not it. Im inheriting from the CustomUI class for this bar script.


Re: Issue Regarding Custom UI

Posted: 07 Jul 2021 09:43
by Elringus

Check UI example project, it has a custom UI set up and working fine.