Bug in 2019.3.0f6 Index was outside the bounds of the array from com.unity.ugui

I try to switch to 2019.3.0f6 and get this error when opening the scene:

IndexOutOfRangeException: Index was outside the bounds of the array.
UnityEngine.UI.Selectable.OnDisable () (at com.unity.ugui/Runtime/UI/Core/Selectable.cs:523)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

AND

IndexOutOfRangeException: Index was outside the bounds of the array.
(wrapper stelemref) System.Object.virt_stelemref_class(intptr,object)

This happens at all Buttons in scene. These are ordinary Unity buttons, without overload.
This prevents me from building an Android project.

If it is a Unity bug you should file a bug report with Unity. Posting to the forum doesn’t necessarily get Unity developer attention.

I just updated my project to 2019.3.0f6; this project has a collection of buttons too but I didn’t get that error. Does this happen only if your project “Current Platform” is set to Android (or whatever it’s called)?

Does the error message still shows when you close your project and restart it?

It has to do with v1.1.4 of Visual Studio Code. The code is way too complex for me. But I found an easy fix. Goto your package manager, and find “Visual Studio Code Editor”, click “See all versions” and update to v1.1.3. This fixes it.

Visual Studio Code v1.1.4 package says “2019.3 verified” but clearly it’s not.

I did report the bug as well.

2 Likes

Error occurs on ALL buttons on the scene. But as it turned out, for this it is enough to have 1 button with override “Enable” method.(Only one button broken all others and you dont understand what is it) So, to fix this error you need call base.Enable from your override method.

I have the same issue with sliders in my project :confused:

Did anyone report this bug? The unity team will not often take action unless you submit a bug report.

I’m getting this on 2019.3.14f1

I submitted a bug report: 1251281

I couldn’t find your bug report - could you please link so I can upvote?

I’ve also gotten this issue in 2019.3.15 on UI.Selectable - had to downgrade to 2019.2, sucks because it took a while to convince management to upgrade :frowning:

Still seems to be a problem in Unity 2019.4. If you ever override Selectable behavior and don’t make sure to call the base.Whatever() method, you’re awash with errors in the console.

I have the same thing occuring for me. I just upgraded to 2019.4 LTS, and everything was working fine before. Now this is occuring all of a sudden. Anyone know the status here?

Make sure that anywhere you override Selectable methods, you call the base method within the override if you can. They do a lot in the “OnSelected” methods and the likes that needs to happen or else they don’t work right.

I dont override any Selectables at all.

Then I can’t offer any better insight as to what’s happening. When I’ve seen that error, it was because one of my scripts overrided some Selectable methods, or a sublcass thereof.

Look in C:\Program Files\Unity\Hub\Editor\2019.3.12f1\Editor\Data\Resources\PackageManager\BuiltInPackages\com.unity.ugui\Runtime\UI\Core\Selectable.cs

You’ll see many virtual functions. One of them is OnEnable().

If you have:
void OnEnable()
{
}
You will get this error. You need to call the base class like this:

void OnEnable()
{
base.OnEnable();
}

That’s what did it for me!

-Ming