Option to automatically select your first Item on Start (DropDownList & AutoCompleteComboBox)

release
LARS-LAPTOP2\larsme 2017-03-27 13:11:24 +02:00
parent 9ac4eb6969
commit b315784caf
2 changed files with 13 additions and 0 deletions

View File

@ -112,11 +112,19 @@ namespace UnityEngine.UI.Extensions
} }
} }
public bool SelectFirstItemOnStart = false;
public void Awake() public void Awake()
{ {
Initialize(); Initialize();
} }
public void Start()
{
if (SelectFirstItemOnStart && AvailableOptions.Count > 0) {
ToggleDropdownPanel (false);
OnItemClicked (AvailableOptions [0]);
}
}
private bool Initialize() private bool Initialize()
{ {

View File

@ -107,10 +107,15 @@ namespace UnityEngine.UI.Extensions
} }
} }
public bool SelectFirstItemOnStart = false;
public void Start() public void Start()
{ {
Initialize(); Initialize();
if (SelectFirstItemOnStart && Items.Count > 0) {
ToggleDropdownPanel (false);
OnItemClicked (0);
}
} }
private bool Initialize() private bool Initialize()