ListViewEnum

Special ListView, TileView and Table to work with enum. Used in combination with ListViewEnum<TEnum>.

ListViewEnum<TEnum> Constructor Arguments

  • listView ListViewEnum

    ListView to display enum values.

  • showObsolete bool = false

    Show obsolete values.

  • long2enum Func<long, TEnum> (optional)

    Custom converter from long to TEnum, use it to avoid memory allocations by default converter.

  • enum2long Func<TEnum, long> (optional)

    Custom converter from TEnum to long, use it to avoid memory allocations by default converter.

ListViewEnum<TEnum> Properties

  • Selected TEnum

    Selected 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;
   }
}