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
- Play Mode framerate drops significantly when moving the mouse cursor with high polling rate
- Create workspace does not update the Unity Version Control and Branch Explorer windows leading to multiple clicks on “Create workspace” which throws an “already exists” error when Creating a workspace with the Branch Explorer window open
- Default and Result encoding properties have blank dropdowns by default when opening the Unity Version Control Settings
- Crash on "StoredGraphicsBuffer::GetGfxBufferID" when activating VFX via extention of Activation Track in Timeline window
- [Linux] Stack trace file path and line number information is missing when IL2CPP Stacktrace Information is set to "Method Name, File Name, and Line Number"
Resolution Note (fix version 2022.1):
Fixed in 2022.1.0a1
Resolution Note (fix version 2021.3):
Fixed in 2021.3.5f1