Author Topic: UIPopuplist question  (Read 3826 times)

dilbertian

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
UIPopuplist question
« 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!
« Last Edit: September 23, 2012, 08:26:54 PM by dilbertian »

joreldraw

  • Guest
Re: UIPopuplist question
« Reply #1 on: September 24, 2012, 01:33:01 AM »
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.

dilbertian

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: UIPopuplist question
« Reply #2 on: September 25, 2012, 08:01:30 PM »
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

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIPopuplist question
« Reply #3 on: September 25, 2012, 08:40:14 PM »
items.Clear().