I have a similar problem, which only occurs on iOS: After some time playing, the buttons and event triggers stop being responsive, as if the event system was no longer in the hierarchy. However, I am sure that it is not a problem related to an absence of the event system, because I made a special function that re-instantiates another one if one is not present in the hierarchy. Furthermore, this problem only occurs in the iOS version of my game, it doesn’t occurs in Android. I’m using Unity 2022.3.22f1
In the Xcode logcat, I got the following error:
NullReferenceException: Object reference not set to an instance of an object.
at UnityEngine.UI.GraphicRaycaster.Raycast (UnityEngine.Canvas canvas, UnityEngine.Camera eventCamera, UnityEngine.Vector2 pointerPosition, System.Collections.Generic.IList1[T] foundGraphics, System.Collections.Generic.List1[T] results) [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.UI.GraphicRaycaster.Raycast (UnityEngine.EventSystems.PointerEventData eventData, System.Collections.Generic.List`1[T] resultAppendList) [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.EventSystems.EventSystem.RaycastAll (UnityEngine.EventSystems.PointerEventData eventData, System.Collections.Generic.List`1[T] raycastResults) [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.EventSystems.PointerInputModule.GetTouchPointerEventData (UnityEngine.Touch input, System.Boolean& pressed, System.Boolean& released) [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.EventSyste<…>
in the editor:
MissingReferenceException: The object of type ‘CanvasRenderer’ 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.UI.GraphicRaycaster.Raycast (UnityEngine.Canvas canvas, UnityEngine.Camera eventCamera, UnityEngine.Vector2 pointerPosition, System.Collections.Generic.IList1[T] foundGraphics, System.Collections.Generic.List1[T] results) (at ./Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/GraphicRaycaster.cs:317)
UnityEngine.UI.GraphicRaycaster.Raycast (UnityEngine.EventSystems.PointerEventData eventData, System.Collections.Generic.List1[T] resultAppendList) (at ./Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/GraphicRaycaster.cs:218) UnityEngine.EventSystems.EventSystem.RaycastAll (UnityEngine.EventSystems.PointerEventData eventData, System.Collections.Generic.List1[T] raycastResults) (at ./Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:276)
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:548)
UnityEngine.EventSystems.StandaloneInputModule.ProcessMouseEvent () (at ./Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/InputModules/StandaloneInputModule.cs:534)
UnityEngine.EventSystems.StandaloneInputModule.Process () (at ./Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/InputModules/StandaloneInputModule.cs:282)
UnityEngine.EventSystems.EventSystem.Update () (at ./Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:530)
Is it a Unity/iOS Bug?