option to set interactible to false if there are no items to be selected (DropDownList and AutoCompleteComboBox)

pull/413/head
LARS-LAPTOP2\larsme 2017-03-27 12:52:51 +02:00
parent 98c92f4cde
commit 9ac4eb6969
2 changed files with 56 additions and 2 deletions

View File

@ -78,7 +78,7 @@ namespace UnityEngine.UI.Extensions
public bool interactible public bool interactible
{ {
get { return _mainInput.interactable || _arrow_Button.interactable; } get { return _mainInput.interactable || _arrow_Button.interactable; }
set { private set {
_mainInput.interactable = value; _mainInput.interactable = value;
_arrow_Button.interactable = value; _arrow_Button.interactable = value;
if (!value && _isPanelActive) { 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() public void Awake()
{ {
Initialize(); Initialize();
@ -215,6 +241,7 @@ namespace UnityEngine.UI.Extensions
panelObjects[_panelItems[i]] = itemObjs[i]; panelObjects[_panelItems[i]] = itemObjs[i];
} }
} }
interactible = _technicallyInteractible && (AvailableOptions.Count > 0 || _remainInteractableIfEmpty);
} }
/// <summary> /// <summary>

View File

@ -74,7 +74,7 @@ namespace UnityEngine.UI.Extensions
public bool interactible public bool interactible
{ {
get { return _mainButton.btn.interactable; } get { return _mainButton.btn.interactable; }
set { private set {
_mainButton.btn.interactable = value; _mainButton.btn.interactable = value;
if (!value && _isPanelActive) { if (!value && _isPanelActive) {
ToggleDropdownPanel (false); 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() public void Start()
{ {
Initialize(); 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 _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) private void OnItemClicked(int indx)