Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Selectable Ondisable index OOB on 2019.3b10

Discussion in '2019.3 Beta' started by Ruonan, Nov 7, 2019.

  1. Ruonan

    Ruonan

    Joined:
    Dec 6, 2012
    Posts:
    53
    Hi I have this simple custom button script that worked fine before 2019.3b10:

    Code (CSharp):
    1. public class ButtonCustom : Button
    2. {
    3.  
    4.     public const string clickSE = "Common_UIright";
    5.  
    6.     protected override void OnEnable()
    7.     {
    8.         base.OnEnable();
    9.         onClick.AddListener(delegate { PlayButtonSE(); });
    10.     }
    11.     protected override void OnDisable()
    12.     {  
    13.         base.OnDisable();
    14.         onClick.RemoveListener(delegate { PlayButtonSE(); });
    15.     }
    16.  
    17.     protected virtual void PlayButtonSE()
    18.     {
    19.         if (Application.isPlaying)
    20.             AudioManager.Instance.PlaySE(clickSE, UIManager.Instance.GetPhoneUI());
    21.     }
    22. }
    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.
     
  2. Ruonan

    Ruonan

    Joined:
    Dec 6, 2012
    Posts:
    53
    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.
     
    jterry likes this.
  3. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,136
    Could you please submit a bug report with a minimal reproduction project for this issue?