public override void Draw() { var options = Variants.Select(t => t.Name).ToList(); if (CanNullable) { options.Insert(0, "null"); } if (!options.Any()) { throw new InvalidDataException("options for select in dropdown not contains any element"); } var index = Variants.FindIndex(t => t.Value.Equals(Selected)); var current_selected = Selected == null ? 0 : index == -1 ? 0 : index + (CanNullable ? 1 : 0); int new_selection; if (Label == null) { new_selection = EditorGUILayout.Popup(current_selected, options.ToArray(), LayoutOptions); } else { new_selection = EditorGUILayout.Popup(new GUIContent(Label), current_selected, options.Select(t => new GUIContent(t)).ToArray(), LayoutOptions); } if (current_selected == new_selection) { return; } var variantValue = Variants.FirstOrDefault(t => t.Name == options[new_selection]); var newSelected = variantValue == null ? default(T) : variantValue.Value; EventChange?.Invoke(newSelected); Selected = newSelected; }