m0_58354079 2021-06-15 09:38 采纳率: 100%
浏览 463
已采纳

Index was outside the bounds of the array.

IndexOutOfRangeException: Index was outside the bounds of the array.
MainUIController.Pause () (at Assets/script/MainUIController.cs:87)
UnityEngine.Events.InvokableCall.Invoke () (at <531e906a5d9447dca62c95ab61ff1c26>:0)
UnityEngine.Events.UnityEvent.Invoke () (at <531e906a5d9447dca62c95ab61ff1c26>:0)
UnityEngine.UI.Button.Press () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/Button.cs:70)
UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/Button.cs:114)
UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/ExecuteEvents.cs:57)
UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/ExecuteEvents.cs:272)
UnityEngine.EventSystems.EventSystem:Update() (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:501)

  • 写回答

2条回答 默认 最新

  • 陈言必行 Unity领域优质创作者 2021-06-15 10:54
    关注

    就是` MainUIController.Pause () `  这个方法里面使用的数组越界了。打断点或者添加日志看下,访问的索引是否包含在其中。还有个误区是访问索引不是int类型的。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?