Search Issue Tracker
Fixed in 2022.1.X
Fixed in 2021.3.X
Votes
0
Found in
2020.3
2021.3
2021.3.2f1
Issue ID
1428922
Regression
No
MissingReferenceException is thrown when calling Object.Destroy from a UI Button
Reproduction steps:
1. Open the attached 'Issue #1231781' project
2. Open the 'SampleScene'
3. Enter Play mode
4. Click on the 'Click here!' button
Expected result: No errors are in the Console
Actual result: 'MissingReferenceException' is in the Console
Reproducible with: 2020.3.34f1, 2021.2.0b1, 2021.3.3f1
Not reproducible with: 2022.1.0a1, 2022.1.1f1, 2022.2.0a15
Could not test with: 2019.4.39f1 (errors after downgrading)
Reproducible on: macOS 11.6 (Intel)
Full error:
MissingReferenceException: The object of type 'TextMeshPro' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
UnityEngine.Component.GetComponent[T] () (at /Users/bokken/buildslave/unity/build/Runtime/Export/Scripting/Component.bindings.cs:42)
UnityEngine.UI.Graphic.get_canvasRenderer () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/Graphic.cs:444)
UnityEngine.UI.GraphicRaycaster.Raycast (UnityEngine.Canvas canvas, UnityEngine.Camera eventCamera, UnityEngine.Vector2 pointerPosition, System.Collections.Generic.IList`1[T] foundGraphics, System.Collections.Generic.List`1[T] results) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/GraphicRaycaster.cs:335)
UnityEngine.UI.GraphicRaycaster.Raycast (UnityEngine.EventSystems.PointerEventData eventData, System.Collections.Generic.List`1[T] resultAppendList) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/GraphicRaycaster.cs:236)
UnityEngine.EventSystems.EventSystem.RaycastAll (UnityEngine.EventSystems.PointerEventData eventData, System.Collections.Generic.List`1[T] raycastResults) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:263)
UnityEngine.EventSystems.PointerInputModule.GetMousePointerEventData (System.Int32 id) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/InputModules/PointerInputModule.cs:295)
UnityEngine.EventSystems.StandaloneInputModule.ProcessMouseEvent (System.Int32 id) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/InputModules/StandaloneInputModule.cs:540)
UnityEngine.EventSystems.StandaloneInputModule.ProcessMouseEvent () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/InputModules/StandaloneInputModule.cs:526)
UnityEngine.EventSystems.StandaloneInputModule.Process () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/InputModules/StandaloneInputModule.cs:280)
UnityEngine.EventSystems.EventSystem.Update () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:501)
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
- Out-of-bounds memory access with multiple CanvasRenderers under a Canvas when using Mesh API
- Package signature validation unexpectedly return an invalid signature status if the validation check is done after the code signing certificate validaty range has passed
- Inspector tries to access file after it was deleted when the file was locked in Inspector window
- Changing Transform values in Search window Inspector loses focus while dragging and stopping mouse without releasing dragging action
- Saving changes on the dirty VFX Graph during the Play mode throws "The referenced script (Unknown) on this Behaviour is missing!" warnings
Resolution Note (fix version 2022.1):
Fixed in 2022.1.0a1
Resolution Note (fix version 2021.3):
Fixed in 2021.3.5f1