private void Awake() { optionsMapping = new Dictionary <string, Type>(); dropDown.OnSelectedOptionChanged.AddListener(() => { chosenType = optionsMapping[dropDown.GetSelectedOption()]; DescriptionAttribute description = chosenType.GetCustomAttribute <DescriptionAttribute>(); if (description != null) { descriptionDisplay.text = description.Description; } } ); Assembly ass = Assembly.GetAssembly(typeof(BaseValueAndColorGenerator)); foreach (Type t in ass.GetTypes().Where(t => t.IsSubclassOf(typeof(BaseValueAndColorGenerator)))) { string s = t.ToString(); s = string.Concat(s.Select(x => char.IsUpper(x) ? " " + x : x.ToString())).TrimStart(' '); optionsMapping.Add(s, t); dropDown.AddOption(s); } }
void Start() { PanelDropdownSelector.ClearOptions(); foreach (var panel in panels) { PanelDropdownSelector.AddOption(panel.name); } PanelDropdownSelector.OnSelectedOptionChanged.AddListener(OnPanelChange); }
void OnNewGenerator(BaseValueAndColorGenerator gen) { this.gen = gen; //set drop down colors for (int i = 0; i < gen.ColorPicker.Colors.Length; i++) { Color c = gen.ColorPicker.Colors[i]; colorDropDown.AddOption(name = $"{i}", c, dropwDownSprite); } }