Selectable Ondisable index OOB on 2019.3b10

Hi I have this simple custom button script that worked fine before 2019.3b10:

public class ButtonCustom : Button
{

    public const string clickSE = "Common_UIright";

    protected override void OnEnable()
    {
        base.OnEnable();
        onClick.AddListener(delegate { PlayButtonSE(); });
    }
    protected override void OnDisable()
    {  
        base.OnDisable();
        onClick.RemoveListener(delegate { PlayButtonSE(); });
    }

    protected virtual void PlayButtonSE()
    {
        if (Application.isPlaying)
            AudioManager.Instance.PlaySE(clickSE, UIManager.Instance.GetPhoneUI());
    }
}

now it throws following error on runtime:

IndexOutOfRangeException: Index was outside the bounds of the array.
UnityEngine.UI.Selectable.OnDisable () (at C:/Program Files/Unity/Hub/Editor/2019.3.0b10/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/UI/Core/Selectable.cs:521)
ButtonCustom.OnDisable () (at Assets/Scripts/UI/Button/ButtonCustom.cs:22)
UnityEngine.GameObject:SetActive(Boolean)
UIScene:SetVisible(Boolean) (at Assets/Scripts/UI/UIScene.cs:14)

I suspect it has something to do with the fix of issue 1160054 about disabled selectable items in 2019.3b10.

Ok it turns out I have another script inherit from ButtonCustom with an empty OnEnable override. Nevertheless there is still a potential OOB threat here.

1 Like

Could you please submit a bug report with a minimal reproduction project for this issue?