In my project, upon opening, I suddenly found three new errors that weren’t there when everything was saved last time I accessed the project.
IndexOutOfRangeException: Index was outside the bounds of the array.
UnityEngine.UI.Selectable.OnDisable () (at ./Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/Selectable.cs:555)
The three were attached to UI buttons in my scene… Then, I hit play to see what the errors were causing to happen (It seemed to not have any effect, but I still want these errors gone) and seven more popped in. Two more of the original three, and five that read:
IndexOutOfRangeException: Index was outside the bounds of the array.
(wrapper stelemref) System.Object.virt_stelemref_class(intptr,object)
UnityEngine.UI.Selectable.OnEnable () (at ./Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/Selectable.cs:518)
Any input or help would be much appreciated, I looked online but couldn’t find many with this issue…
Selectables are types of UI elements in UGUI. When they each fire OnEnable() and OnDisable(), they're supposed to register as current selectables in the s_Selectables array. The array is set up to double in size before new registrations exceed its current limit, so it appears the opposite probably caused your bug: one or more items attempted to unregister more than once. That would decrement s_SelectableCount below zero, causing IndexOutOfRange. The scene you've opened has a canvas, yes? Do you have any editor scripts proactively disabling UI elements on scene load? Might be related.
– VRARDAJ