IndexOutOfRangeException error without any reason

Hi,please can someone tell me why this error happened, and what does it mean?

IndexOutOfRangeException: Index 23 is out of range of ‘23’ Length.
Unity.Collections.NativeArray1[T].FailOutOfRangeError (System.Int32 index) (at <94c5f4c38cdc42d2b006f8badef04394>:0) Unity.Collections.NativeArray1[T].CheckElementReadAccess (System.Int32 index) (at <94c5f4c38cdc42d2b006f8badef04394>:0)
Unity.Collections.NativeArray`1[T].get_Item (System.Int32 index) (at <94c5f4c38cdc42d2b006f8badef04394>:0)
Unity.Entities.Editor.EntityArrayListAdapter+Enumerator.UpdateIndexInChunk () (at Library/PackageCache/com.unity.entities@0.6.0-preview.24/Unity.Entities.Editor/EntityDebugger/EntityArrayListAdapter.cs:58)
Unity.Entities.Editor.EntityArrayListAdapter+Enumerator.MoveToIndex (System.Int32 newLinearIndex) (at Library/PackageCache/com.unity.entities@0.6.0-preview.24/Unity.Entities.Editor/EntityDebugger/EntityArrayListAdapter.cs:68)
Unity.Entities.Editor.EntityArrayListAdapter.get_Item (System.Int32 linearIndex) (at Library/PackageCache/com.unity.entities@0.6.0-preview.24/Unity.Entities.Editor/EntityDebugger/EntityArrayListAdapter.cs:132)
UnityEditor.IMGUI.Controls.TreeViewDataSource.GetItem (System.Int32 row) (at <9a184ab867bb42c296d20ace04f48df3>:0)
UnityEditor.IMGUI.Controls.TreeViewController.IterateVisibleItems (System.Int32 firstRow, System.Int32 numVisibleRows, System.Single rowWidth, System.Boolean hasFocus) (at <9a184ab867bb42c296d20ace04f48df3>:0)
UnityEditor.IMGUI.Controls.TreeViewController.OnGUI (UnityEngine.Rect rect, System.Int32 keyboardControlID) (at <9a184ab867bb42c296d20ace04f48df3>:0)
UnityEditor.IMGUI.Controls.TreeView.TreeViewWithMultiColumnHeader (UnityEngine.Rect rect) (at <9a184ab867bb42c296d20ace04f48df3>:0)
UnityEditor.IMGUI.Controls.TreeView.OnGUI (UnityEngine.Rect rect) (at <9a184ab867bb42c296d20ace04f48df3>:0)
Unity.Entities.Editor.EntityDebugger.EntityList () (at Library/PackageCache/com.unity.entities@0.6.0-preview.24/Unity.Entities.Editor/EntityDebugger/EntityDebugger.cs:487)
Unity.Entities.Editor.EntityDebugger.OnGUI () (at Library/PackageCache/com.unity.entities@0.6.0-preview.24/Unity.Entities.Editor/EntityDebugger/EntityDebugger.cs:567)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[ ] parameters, System.Globalization.CultureInfo culture) (at <437ba245d8404784b9fbab9b439ac908>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[ ] parameters, System.Globalization.CultureInfo culture) (at <437ba245d8404784b9fbab9b439ac908>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[ ] parameters) (at <437ba245d8404784b9fbab9b439ac908>:0)
UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at <9a184ab867bb42c296d20ace04f48df3>:0)
UnityEditor.HostView.Invoke (System.String methodName) (at <9a184ab867bb42c296d20ace04f48df3>:0)
UnityEditor.HostView.InvokeOnGUI (UnityEngine.Rect onGUIPosition, UnityEngine.Rect viewRect) (at <9a184ab867bb42c296d20ace04f48df3>:0)
UnityEditor.DockArea.DrawView (UnityEngine.Rect viewRect, UnityEngine.Rect dockAreaRect) (at <9a184ab867bb42c296d20ace04f48df3>:0)
UnityEditor.DockArea.OldOnGUI () (at <9a184ab867bb42c296d20ace04f48df3>:0)
UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 parentTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout, UnityEngine.Rect layoutSize, System.Boolean canAffectFocus) (at <57fa7f4ad1c34ed185465e0a9f71c244>:0)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect, System.Boolean canAffectFocus) (at <57fa7f4ad1c34ed185465e0a9f71c244>:0)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Boolean canAffectFocus) (at <57fa7f4ad1c34ed185465e0a9f71c244>:0)
UnityEngine.UIElements.IMGUIContainer.SendEventToIMGUI (UnityEngine.UIElements.EventBase evt, System.Boolean canAffectFocus) (at <57fa7f4ad1c34ed185465e0a9f71c244>:0)
UnityEngine.UIElements.IMGUIContainer.HandleEvent (UnityEngine.UIElements.EventBase evt) (at <57fa7f4ad1c34ed185465e0a9f71c244>:0)
UnityEngine.UIElements.EventDispatchUtilities.PropagateEvent (UnityEngine.UIElements.EventBase evt) (at <57fa7f4ad1c34ed185465e0a9f71c244>:0)
UnityEngine.UIElements.MouseEventDispatchingStrategy.DispatchEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <57fa7f4ad1c34ed185465e0a9f71c244>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <57fa7f4ad1c34ed185465e0a9f71c244>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEventQueue () (at <57fa7f4ad1c34ed185465e0a9f71c244>:0)
UnityEngine.UIElements.EventDispatcher.OpenGate () (at <57fa7f4ad1c34ed185465e0a9f71c244>:0)
UnityEngine.UIElements.EventDispatcherGate.Dispose () (at <57fa7f4ad1c34ed185465e0a9f71c244>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <57fa7f4ad1c34ed185465e0a9f71c244>:0)
UnityEngine.UIElements.EventDispatcher.Dispatch (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, UnityEngine.UIElements.DispatchMode dispatchMode) (at <57fa7f4ad1c34ed185465e0a9f71c244>:0)
UnityEngine.UIElements.BaseVisualElementPanel.SendEvent (UnityEngine.UIElements.EventBase e, UnityEngine.UIElements.DispatchMode dispatchMode) (at <57fa7f4ad1c34ed185465e0a9f71c244>:0)
UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at <57fa7f4ad1c34ed185465e0a9f71c244>:0)
UnityEngine.UIElements.UIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at <57fa7f4ad1c34ed185465e0a9f71c244>:0)
UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at <59837000ebf54955a9cb1d31caa86097>:0)

Your NativeArray has 23 elements. The first one is 0 and the last one is 22. Array[23] would be the 24th element, which doesn’t exist.

1 Like

yes but i dont have a NativeArray with 23 elements,i don’t know why this error appears and it always says Index 23 is out of range of ‘23’ Length regardless of entities number in the scene

Does this error appear when EntityDebugger enabled with selected entity and you exit play mode? Because it’s entity debugger UI error which doesn’t affect any your gameplay logic.

1 Like

yes EntityDebugger enabled but the error appear during the play mode and there is no specific time, it just happens suddenly