Exception occurs when I create a new Rule Tile

Whenever I create a Rule Tile I get an ArgumentOutOfRangeException. If I try to ignore it and use the Rule Tile. I tried to ignore it but Unity became unresponsive and crashed. How can I resolve this?

ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
System.Collections.Generic.List`1[T].get_Item (System.Int32 index) (at <6073cf49ed704e958b8a66d540dea948>:0)
UnityEditor.RuleTileEditor.GetElementHeight (System.Int32 index) (at Library/PackageCache/com.unity.2d.tilemap.extras@2.2.3/Editor/Tiles/RuleTile/RuleTileEditor.cs:293)
UnityEditorInternal.ReorderableList.CacheIfNeeded () (at <1135c66e5f4c41a7831fa5798849d8b6>:0)
UnityEditorInternal.ReorderableList.DoListElements (UnityEngine.Rect listRect, UnityEngine.Rect visibleRect) (at <1135c66e5f4c41a7831fa5798849d8b6>:0)
UnityEditorInternal.ReorderableList.DoLayoutList () (at <1135c66e5f4c41a7831fa5798849d8b6>:0)
UnityEditor.RuleTileEditor.OnInspectorGUI () (at Library/PackageCache/com.unity.2d.tilemap.extras@2.2.3/Editor/Tiles/RuleTile/RuleTileEditor.cs:545)
UnityEditor.UIElements.InspectorElement+<>c__DisplayClass59_0.<CreateIMGUIInspectorFromEditor>b__0 () (at <78eb217972d24c1381fc135c94c21a2c>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

Hi,

ArgumentOutOfRange / IndexOutOfRange exception means that the code tried to access a non-existent index in an array, List or another collection. The first index in an array and List is 0, hence the last index is the length minus 1. For example, if the array has got a length of 2, and the code tries to access index 2, you will get this error message because there are only two “slots” in the array: at index 0 and at index 1.

Did this help?


See also:

Hi Nina I understand what the Exception is. My problem is that my code is not causing this. In fact I have no code. I start a new empty 2D project, create a new Rule Tile and this happens.

Oh, I see. Which version of Unity do you use? And did you check if there is an update for the Tilemap package in Window > Package Manager?

If nothing helped: Maybe you could delete the tile rules and recreate them.

I’m using Unity version 2021.3.1f1, both 2D Tilemap Editor and 2D Tilemap Extras packages are up to date.

The issue happens immediately when I create a new empty Rule Tile in my assets. It seems to happen because there are no Tiling Rules. Adding a Tiling Rule to the list in the inspector makes it stop happening.

Thank you very much for your help!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms