Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: dilbertian on September 23, 2012, 08:15:00 PM
-
I have a dialog in my game UI that allows a player to select between different species. I would like to dynamically populate the UIPopuplist.Options (via my C# code) based on that species selection, but there does not appear to be an exposed method or property that I can find.
Also, at one point I am trying to disable the UIPopuplist if only a single option is available, but its .enabled property does not appear to do anything to the behavior although I can see via the editor that it is clearly unchecking the enabled checkbox on the UIPopuplist script component. I would expect if I set it's .enabled=false, the drop-down would change to a disabled color and the dropdown would cease to respond.
Any help would be appreciated!
-
You can fill and remove elements in the list with this:
mList = gameObject.GetComponent<UIPopupList>();
mList.items.Remove(string item)
mList.items.Removeall();
mList.items.RemoveAt(int index);
mList.items.RemoveRange(int index, int count);
mList.items.Add(string item);
mList.items.AddRange(Ienumerable<string> collection);
About disable color, i think the enable not work properly for your need, this only shutdown the UIPopuplist component.
You can try to make disable the collider and change your sprite color manually.
-
The .items.Add() worked fine but the .RemoveAll() appears to require a predicate and not sure what to pass it. I will check the manual and see what it recommends.
Thanks again!
-Tim
-
items.Clear().