public static List <TMP_Dropdown.OptionData> EnumToOptionDataList <T>() { if (typeof(T).IsEnum) { TMP_Dropdown.OptionDataList optionList = new TMP_Dropdown.OptionDataList(); List <T> list = EnumToList <T>(); list.ForEach(l => optionList.options.Add(new TMP_Dropdown.OptionData(l.ToString()))); return(optionList.options); } throw new ArgumentException("<T> must be enum"); }
private const string sortAllName = "All";// Just to make it easier, when sorting private void Start() { if (mapEvents == null) { enabled = false; } if (sortDropDown != null) { List <WorldMaps> worldMaps = ((WorldMaps[])System.Enum.GetValues(typeof(WorldMaps))).ToList(); TMP_Dropdown.OptionDataList optionDataList = new TMP_Dropdown.OptionDataList(); worldMaps.ForEach(w => optionDataList.options.Add(new TMP_Dropdown.OptionData(w.ToString()))); sortDropDown.ClearOptions(); sortDropDown.options.Add(new TMP_Dropdown.OptionData(sortAllName)); sortDropDown.AddOptions(optionDataList.options); sortDropDown.onValueChanged.AddListener(delegate { ListSortedByWorldTeleports(sortDropDown); }); } }