Search Issue Tracker
Won't Fix
Votes
0
Found in
2019.1.0a11
2019.1.0a14
Issue ID
1117136
Regression
Yes
Functions called by UI Toggles before Start() resulting in NullReferenceException spam
Repro step:
- download and open this project
- press play
- notice the Null Reference exceptions:
NullReferenceException: Object reference not set to an instance of an object
Rolloff.ChangeRolloff () (at Assets/Audio Manager/Rolloff.cs:43)
UnityEngine.Events.InvokableCall.Invoke () (at C:/buildslave/unity/build/Runtime/Export/UnityEvent/UnityEvent.cs:166)
UnityEngine.Events.UnityEvent`1[System.Boolean].Invoke (Boolean arg0) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent/UnityEvent/UnityEvent_1.cs:63)
UnityEngine.UI.Toggle.Set (Boolean value, Boolean sendCallback) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Toggle.cs:274)
UnityEngine.UI.Toggle.set_isOn (Boolean value) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Toggle.cs:237)
UnityEngine.UI.ToggleGroup.RegisterToggle (UnityEngine.UI.Toggle toggle) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/ToggleGroup.cs:87)
UnityEngine.UI.Toggle.SetToggleGroup (UnityEngine.UI.ToggleGroup newGroup, Boolean setMemberValue) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Toggle.cs:185)
UnityEngine.UI.Toggle.OnEnable () (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Toggle.cs:144)
- This is because the ChangeRolloff function- assigned to an UI Toggle, is called before Start() of the main Rolloff class and, therefore the objects inside don't get initialised
- also, on exiting play mode, the ChangeRolloff toggle gets activated again causing more errors in the console:
Assertion failed on expression: 'go.IsActive()'
UnityEngine.GameObject:Find(String)
Rolloff:ChangeRolloff() (at Assets/Audio Manager/Rolloff.cs:47)
UnityEngine.UI.Toggle:OnDisable()
Cannot reproduce with: 2019.1.0a10 and 2018.3.1f1
Reproducible with: 2019.1.0a11 and 2019.2.0a1
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Redoing creation of Sub Scenes and Cube GameObjects in Hierarchy throws “Assertion failed on expression: 'targetScene != nullptr’” error in Console window
- Selecting “New Sub Scene” after assigning “New Scene” in Sub Scene Script Component throws “Destroying GameObjects immediately is not permitted” in the Console window
- Shader Graph "Zoom Step Size" can be set to 0 even though the zoom still works
- Enabling/Disabling the Deprecated Nodes doesn't apply to the opened Shader Graph unless any Variable is added to the Blackboard
- Group Selection title text size is smaller in renaming than the actual font size
Resolution Note (2019.2.X):
The UI needs to send the notification when it is ensuring only 1 toggle is on when you enter play mode. The issue is this code does run before Start. User project needs to change to prevent the null reference from happening. Ensure the object you are accessing is not null is good practice.