parent
b9ad53470f
commit
3429d37f14
|
@ -213,6 +213,43 @@ namespace UnityEngine.UI.Extensions
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
public void AddItem(string item)
|
||||||
|
{
|
||||||
|
AvailableOptions.Add(item);
|
||||||
|
RebuildPanel();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveItem(string item)
|
||||||
|
{
|
||||||
|
AvailableOptions.Remove(item);
|
||||||
|
RebuildPanel();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetAvailableOptions(List<string> newOptions)
|
||||||
|
{
|
||||||
|
AvailableOptions.Clear();
|
||||||
|
AvailableOptions = newOptions;
|
||||||
|
RebuildPanel();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetAvailableOptions(string[] newOptions)
|
||||||
|
{
|
||||||
|
AvailableOptions.Clear();
|
||||||
|
|
||||||
|
for (int i = 0; i < newOptions.Length; i++)
|
||||||
|
{
|
||||||
|
AvailableOptions.Add(newOptions[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
RebuildPanel();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ResetItems()
|
||||||
|
{
|
||||||
|
AvailableOptions.Clear();
|
||||||
|
RebuildPanel();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Rebuilds the contents of the panel in response to items being added.
|
/// Rebuilds the contents of the panel in response to items being added.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -131,34 +131,41 @@ namespace UnityEngine.UI.Extensions
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* currently just using items in the list instead of being able to add to it.
|
public void AddItem(string item)
|
||||||
public void AddItems(params object[] list)
|
|
||||||
{
|
{
|
||||||
List<DropDownListItem> ddItems = new List<DropDownListItem>();
|
AvailableOptions.Add(item);
|
||||||
foreach (var obj in list)
|
RebuildPanel();
|
||||||
{
|
}
|
||||||
if (obj is DropDownListItem)
|
|
||||||
{
|
public void RemoveItem(string item)
|
||||||
ddItems.Add((DropDownListItem)obj);
|
{
|
||||||
}
|
AvailableOptions.Remove(item);
|
||||||
else if (obj is string)
|
RebuildPanel();
|
||||||
{
|
}
|
||||||
ddItems.Add(new DropDownListItem(caption: (string)obj));
|
|
||||||
}
|
public void SetAvailableOptions(List<string> newOptions)
|
||||||
else if (obj is Sprite)
|
{
|
||||||
{
|
AvailableOptions.Clear();
|
||||||
ddItems.Add(new DropDownListItem(image: (Sprite)obj));
|
AvailableOptions = newOptions;
|
||||||
}
|
RebuildPanel();
|
||||||
else
|
}
|
||||||
{
|
|
||||||
throw new System.Exception("Only ComboBoxItems, Strings, and Sprite types are allowed");
|
public void SetAvailableOptions(string[] newOptions)
|
||||||
}
|
{
|
||||||
}
|
AvailableOptions.Clear();
|
||||||
Items.AddRange(ddItems);
|
|
||||||
Items = Items.Distinct().ToList();//remove any duplicates
|
for (int i = 0; i < newOptions.Length; i++)
|
||||||
|
{
|
||||||
|
AvailableOptions.Add(newOptions[i]);
|
||||||
|
}
|
||||||
|
RebuildPanel();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ResetItems()
|
||||||
|
{
|
||||||
|
AvailableOptions.Clear();
|
||||||
RebuildPanel();
|
RebuildPanel();
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Rebuilds the contents of the panel in response to items being added.
|
/// Rebuilds the contents of the panel in response to items being added.
|
||||||
|
|
Loading…
Reference in New Issue