diff --git a/Scripts/Controls/ComboBox/AutoCompleteComboBox.cs b/Scripts/Controls/ComboBox/AutoCompleteComboBox.cs index fefe5ea..f637406 100644 --- a/Scripts/Controls/ComboBox/AutoCompleteComboBox.cs +++ b/Scripts/Controls/ComboBox/AutoCompleteComboBox.cs @@ -78,7 +78,7 @@ namespace UnityEngine.UI.Extensions public bool interactible { get { return _mainInput.interactable || _arrow_Button.interactable; } - set { + private set { _mainInput.interactable = value; _arrow_Button.interactable = value; if (!value && _isPanelActive) { @@ -87,6 +87,32 @@ namespace UnityEngine.UI.Extensions } } + [SerializeField] + //I couldn't come up with a better name + private bool _technicallyInteractible = true; + public bool TechnicallyInteractible + { + get { return _technicallyInteractible; } + set + { + _technicallyInteractible = value; + interactible = _technicallyInteractible && (AvailableOptions.Count > 0 || _remainInteractableIfEmpty); + } + } + + [SerializeField] + private bool _remainInteractableIfEmpty = true; + public bool RemainInteractableIfEmpty + { + get { return _remainInteractableIfEmpty; } + set + { + _remainInteractableIfEmpty = value; + interactible = _technicallyInteractible && (AvailableOptions.Count > 0 || _remainInteractableIfEmpty); + } + } + + public void Awake() { Initialize(); @@ -215,6 +241,7 @@ namespace UnityEngine.UI.Extensions panelObjects[_panelItems[i]] = itemObjs[i]; } } + interactible = _technicallyInteractible && (AvailableOptions.Count > 0 || _remainInteractableIfEmpty); } /// diff --git a/Scripts/Controls/ComboBox/DropDownList.cs b/Scripts/Controls/ComboBox/DropDownList.cs index 6c0f184..b4bfd33 100644 --- a/Scripts/Controls/ComboBox/DropDownList.cs +++ b/Scripts/Controls/ComboBox/DropDownList.cs @@ -74,7 +74,7 @@ namespace UnityEngine.UI.Extensions public bool interactible { get { return _mainButton.btn.interactable; } - set { + private set { _mainButton.btn.interactable = value; if (!value && _isPanelActive) { ToggleDropdownPanel (false); @@ -82,6 +82,32 @@ namespace UnityEngine.UI.Extensions } } + [SerializeField] + //I couldn't come up with a better name + private bool _technicallyInteractible = true; + public bool TechnicallyInteractible + { + get { return _technicallyInteractible; } + set + { + _technicallyInteractible = value; + interactible = _technicallyInteractible && (Items.Count > 0 || _remainInteractableIfEmpty); + } + } + + [SerializeField] + private bool _remainInteractableIfEmpty = true; + public bool RemainInteractableIfEmpty + { + get { return _remainInteractableIfEmpty; } + set + { + _remainInteractableIfEmpty = value; + interactible = _technicallyInteractible && (Items.Count > 0 || _remainInteractableIfEmpty); + } + } + + public void Start() { Initialize(); @@ -202,6 +228,7 @@ namespace UnityEngine.UI.Extensions } _panelItems[i].gameobject.SetActive(i < Items.Count);// if we have more thanks in the panel than Items in the list hide them } + interactible = _technicallyInteractible && (Items.Count > 0 || _remainInteractableIfEmpty); } private void OnItemClicked(int indx)