Option to change Input Text Color based on matching Items
parent
b315784caf
commit
6565b1a6d1
|
@ -114,6 +114,26 @@ namespace UnityEngine.UI.Extensions
|
||||||
|
|
||||||
public bool SelectFirstItemOnStart = false;
|
public bool SelectFirstItemOnStart = false;
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
private bool _ChangeInputTextColorBasedOnMatchingItems = false;
|
||||||
|
public bool ChangeInputTextColorBasedOnMatchingItems{
|
||||||
|
get { return _remainInteractableIfEmpty; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_ChangeInputTextColorBasedOnMatchingItems = value;
|
||||||
|
if (_ChangeInputTextColorBasedOnMatchingItems) {
|
||||||
|
SetInputTextColor ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO design as foldout for Inspector
|
||||||
|
public Color ValidSelectionTextColor = Color.green;
|
||||||
|
public Color MatchingItemsRemainingTextColor = Color.black;
|
||||||
|
public Color NoItemsRemainingTextColor = Color.red;
|
||||||
|
|
||||||
|
private bool _selectionIsValid = false;
|
||||||
|
|
||||||
public void Awake()
|
public void Awake()
|
||||||
{
|
{
|
||||||
Initialize();
|
Initialize();
|
||||||
|
@ -250,6 +270,7 @@ namespace UnityEngine.UI.Extensions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
interactible = _technicallyInteractible && (AvailableOptions.Count > 0 || _remainInteractableIfEmpty);
|
interactible = _technicallyInteractible && (AvailableOptions.Count > 0 || _remainInteractableIfEmpty);
|
||||||
|
SetInputTextColor ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -348,8 +369,24 @@ namespace UnityEngine.UI.Extensions
|
||||||
{
|
{
|
||||||
ToggleDropdownPanel(false);
|
ToggleDropdownPanel(false);
|
||||||
}
|
}
|
||||||
|
_selectionIsValid = _panelItems.Contains (Text);
|
||||||
|
SetInputTextColor ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SetInputTextColor(){
|
||||||
|
if (ChangeInputTextColorBasedOnMatchingItems) {
|
||||||
|
if (_selectionIsValid) {
|
||||||
|
_mainInput.textComponent.color = ValidSelectionTextColor;
|
||||||
|
} else if (_panelItems.Count > 0) {
|
||||||
|
_mainInput.textComponent.color = MatchingItemsRemainingTextColor;
|
||||||
|
} else {
|
||||||
|
_mainInput.textComponent.color = NoItemsRemainingTextColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Toggle the drop down list
|
/// Toggle the drop down list
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Reference in New Issue