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
- Incorrect rotations on bones when importing FBX animations with a Humanoid Rig
- Render Graph Viewer “Pass List” section is flickering when resizing vertically and the Render Graph Viewer window is docked
- Render Graph Viewer Capture button plays the click animation but does not do anything when the Capture button is pressed with the “Enter” key on the keyboard
- UI Builder Scrollview is unable to scroll all the way down when the window is downsized vertically
- Celestial bodies order remains unchanged when the Distance setting is modified
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.