ListViewEnum
Special ListView, TileView and Table (DataGrid) to work with enum.
Used in combination with ListViewEnum<TEnum>.
ListViewEnum<TEnum> Constructor Arguments
listView
ListViewEnumListView to display
enumvalues.showObsolete
bool=falseShow obsolete values.
long2enum
Func<long, TEnum>(optional)Custom converter from
longtoTEnum, use it to avoid memory allocations by default converter.enum2long
Func<TEnum, long>(optional)Custom converter from
TEnumtolong, use it to avoid memory allocations by default converter.
ListViewEnum<TEnum> Properties
Selected
TEnumSelected value.
Example
public class TestListViewEnum : MonoBehaviour
{
[SerializeField]
protected ListViewEnum ListView;
ListViewEnum<AdditionalCanvasShaderChannels> Wrapper;
protected void Start()
{
ListView.OnSelectObject.AddListener(ValueChanged);
ListView.OnDeselectObject.AddListener(ValueChanged);
Wrapper = ListView.UseEnum<AdditionalCanvasShaderChannels>(false, x => (AdditionalCanvasShaderChannels)x);
}
protected void OnDestroy()
{
if (ListView != null)
{
ListView.OnSelectObject.RemoveListener(ValueChanged);
ListView.OnDeselectObject.RemoveListener(ValueChanged);
}
}
void ValueChanged(int index)
{
Debug.Log(string.Format("selected: {0}", EnumHelper<AdditionalCanvasShaderChannels>.ToString(Wrapper.Selected)));
}
/// <summary>
/// Select values.
/// </summary>
public void Select()
{
WrapperWithFlags.Selected = AdditionalCanvasShaderChannels.Normal | AdditionalCanvasShaderChannels.TexCoord1;
}
}