尽管事件系统存在,Unity UI 在 iOS 上一段时间后没有响应[已解决]

问题描述 投票:0回答:1

在我的 Unity 项目中,我遇到一个问题,该问题仅发生在 iOS 构建版本上:播放一段时间后,按钮和事件触发器停止响应,就好像事件系统不再位于层次结构中一样。但是,我确信这不是与事件系统缺失相关的问题,因为我创建了一个特殊函数,如果层次结构中不存在事件系统,则可以重新实例化另一个事件系统。另外,这个问题只出现在我的游戏的iOS版本中,在Android中不会出现。我使用的是 Unity 2022.3.22f1 for iOS 版本。

在 Xcode logcat 中,以下内容:

NullReferenceException:未将对象引用设置为对象的实例。 在UnityEngine.UI.GraphicRaycaster.Raycast(UnityEngine.Canvas画布,UnityEngine.Camera eventCamera,UnityEngine.Vector2pointerPosition,System.Collections.Generic.IList

1[T] foundGraphics, System.Collections.Generic.List
1[T]结果)[0x00000]中<00000000000000000000000000000000>:0 在 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] 中 <00000000000000000000000000000000>:0 在UnityEngine.EventSystems.PointerInputModule.GetTouchPointerEventData(UnityEngine.Touch输入,System.Boolean&按下,System.Boolean&释放)[0x00000]在<00000000000000000000000000000000>:0 在 UnityEngine.EventSyste<…>

在编辑器中: MissingReferenceException:“CanvasRenderer”类型的对象已被销毁,但您仍在尝试访问它。 您的脚本应该检查它是否为空,或者您不应该销毁该对象。 UnityEngine.UI.GraphicRaycaster.Raycast(UnityEngine.Canvas画布、UnityEngine.Camera eventCamera、UnityEngine.Vector2pointerPosition、System.Collections.Generic.IList

1[T] foundGraphics, System.Collections.Generic.List
1[T]结果)(位于./Library/PackageCache/[email]受保护]/Runtime/UI/Core/GraphicRaycaster.cs:317) UnityEngine.UI.GraphicRaycaster.Raycast(UnityEngine.EventSystems.PointerEventData eventData、System.Collections.Generic.List
1[T] resultAppendList) (at ./Library/PackageCache/[email protected]/Runtime/UI/Core/GraphicRaycaster.cs:218) UnityEngine.EventSystems.EventSystem.RaycastAll (UnityEngine.EventSystems.PointerEventData eventData, System.Collections.Generic.List
1[T] raycastResults)(位于 ./Library/PackageCache/[电子邮件受保护]/Runtime/EventSystem/事件系统.cs:276) UnityEngine.EventSystems.PointerInputModule.GetMousePointerEventData(System.Int32 id)(位于 ./Library/PackageCache/[电子邮件受保护]/Runtime/EventSystem/InputModules/PointerInputModule.cs:295) UnityEngine.EventSystems.StandaloneInputModule.ProcessMouseEvent(System.Int32 id)(位于 ./Library/PackageCache/[电子邮件受保护]/Runtime/EventSystem/InputModules/StandaloneInputModule.cs:548) UnityEngine.EventSystems.StandaloneInputModule.ProcessMouseEvent ()(位于 ./Library/PackageCache/[电子邮件受保护]/Runtime/EventSystem/InputModules/StandaloneInputModule.cs:534) UnityEngine.EventSystems.StandaloneInputModule.Process ()(位于 ./Library/PackageCache/[电子邮件受保护]/Runtime/EventSystem/InputModules/StandaloneInputModule.cs:282) UnityEngine.EventSystems.EventSystem.Update ()(位于 ./Library/PackageCache/[电子邮件受保护]/Runtime/EventSystem/EventSystem.cs:530)

这是 Unity/iOS 的错误吗?

ios unity-game-engine user-interface
1个回答
0
投票

我解决了。该问题是由我打开但未关闭的委托生成的。我在这里找到了解决方案https://forum.unity.com/threads/the...l-trying-to-access-it-your-script-sho.277287/

© www.soinside.com 2019 - 2024. All rights reserved.