Question by
StonedLover · Mar 04, 2016 at 10:31 AM ·
c#guidropdown
How delete options from the dropdown gui withscript?
Heyho, I mage a GUI where u got some buttons if u hit one a list of gameobjects are loaded from resources and a dropdown menu is filled with option. Now I got to my problem. How Can I delete the dorpown.options which are curently created ? I tried .ClearList but this doesnt work any Ideas?
Here is a lil bit of my code which is relevant to this problem:
public void LoadShopsSpec()
{
_dropdown.gameObject.SetActive(true);
SpawnPlaceHouse = ShopSpec;
string ShopsSpec = "ShopsSpec";
InitGui(ShopsSpec);
}
public void LoadShopsCorner()
{
_dropdown.gameObject.SetActive(true);
SpawnPlaceHouse = ShopCor;
string ShopsCorner = "ShopsCorner";
InitGui(ShopsCorner);
}
void InitGui(string BuildingType)
{
if(_buildings != null) Array.Clear(_buildings, 0, _buildings.Length);
_buildings = Resources.LoadAll<GameObject>(BuildingType);
foreach (GameObject buil in _buildings)
{
GameObject buils = buil.gameObject;
string building_ = buil.name;
_buildingsname.Add(building_);
}
foreach (string c in _buildingsname)
{
_dropdown.options.Add(new Dropdown.OptionData() { text = c });
}
}
Comment
Your answer
Follow this Question
Related Questions
Change graphics with Dropdown 0 Answers
Unity Dropdown Menu Not Closing 1 Answer
Location Does Not Change 1 Answer
separate the items of an array with lines 1 Answer
Instantiated Buttons to have separate On-click functions 0 Answers