I seem to have hit a problem in destroying GUI Panels that causes rendering logic to get upset. After I destroy a GUI Panel (with lots of content inside, if that makes a difference) and instantiate a prefab of a new Panel, I get a MissingReferenceException when I put the mouse over the game view panel in the editor. If I unpause out of the error and put the mouse back in the game view the exception pops up again. Based on the error information in the console, it looks like rendering logic thinks that an image still exists in the Canvas, and it gets upset when it cannot find it.
I have submitted a bug report, but I am curious to see if anyone else has conquered this problem. The full MissingReferenceException text follows:
MissingReferenceException: The object
of type ‘Image’ 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[CanvasRenderer]
() (at
C:/BuildAgent/work/d63dfc6385190b60/artifacts/EditorGenerated/UnityEngineComponent.cs:189)
UnityEngine.UI.Graphic.get_canvasRenderer
() (at
C:/BuildAgent/work/d63dfc6385190b60/Extensions/guisystem/guisystem/UI/Core/Graphic.cs:193)
UnityEngine.UI.Graphic.get_depth ()
(at
C:/BuildAgent/work/d63dfc6385190b60/Extensions/guisystem/guisystem/UI/Core/Graphic.cs:154)
UnityEngine.UI.GraphicRaycaster.Raycast
(UnityEngine.Canvas canvas,
UnityEngine.Camera eventCamera,
Vector2 pointerPosition,
System.Collections.Generic.List1 results) (at C:/BuildAgent/work/d63dfc6385190b60/Extensions/guisystem/guisystem/UI/Core/GraphicRaycaster.cs:180) UnityEngine.UI.GraphicRaycaster.Raycast (UnityEngine.EventSystems.PointerEventData eventData, System.Collections.Generic.List
1
resultAppendList) (at
C:/BuildAgent/work/d63dfc6385190b60/Extensions/guisystem/guisystem/UI/Core/GraphicRaycaster.cs:104)
UnityEngine.EventSystems.EventSystem.RaycastAll
(UnityEngine.EventSystems.PointerEventData
eventData,
System.Collections.Generic.List`1
raycastResults) (at
C:/BuildAgent/work/d63dfc6385190b60/Extensions/guisystem/guisystem/EventSystem/EventSystem.cs:134)
UnityEngine.EventSystems.PointerInputModule.GetMousePointerEventData
() (at
C:/BuildAgent/work/d63dfc6385190b60/Extensions/guisystem/guisystem/EventSystem/InputModules/PointerInputModule.cs:145)
UnityEngine.EventSystems.StandaloneInputModule.ProcessMouseEvent
() (at
C:/BuildAgent/work/d63dfc6385190b60/Extensions/guisystem/guisystem/EventSystem/InputModules/StandaloneInputModule.cs:276)
UnityEngine.EventSystems.StandaloneInputModule.Process
() (at
C:/BuildAgent/work/d63dfc6385190b60/Extensions/guisystem/guisystem/EventSystem/InputModules/StandaloneInputModule.cs:159)
UnityEngine.EventSystems.EventSystem.Update
() (at
C:/BuildAgent/work/d63dfc6385190b60/Extensions/guisystem/guisystem/EventSystem/EventSystem.cs:228)