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
- Active quality level set on a new Universal 2D project is not the default quality level when creating a new project
- Inspector Open button does nothing when navigating to a different folder with a locked asset
- Pre-generated XML serializers fail to deserialize types that use polymorphism when the Player is built with the IL2CPP scripting backend
- Editor crashes with error "Failed to present D3D11 swapchain due to device reset/removed" and Player freezes when rendering a particle system while using modified URP package on DX11
- Crash on Scripting::LogException when async HTTP callback executes after scripting domain teardown
Resolution Note (fix version 2022.1):
Fixed in 2022.1.0a1
Resolution Note (fix version 2021.3):
Fixed in 2021.3.5f1