using System; using System.Collections.Generic; using System.Linq; using UnityEditor; namespace Unity.VisualScripting { public class DropdownOption : IDropdownOption { public DropdownOption(object value) { this.value = value; label = value != null ? value.ToString() : "(null)"; } public DropdownOption(object value, string label) { this.value = value; this.label = label; } public string label { get; set; } public virtual string popupLabel => label; public object value { get; set; } private static IEnumerable GetEnumOptions(bool nicify) { foreach (var enumValue in Enum.GetValues(typeof(T)).Cast()) { yield return new DropdownOption(enumValue, nicify ? ObjectNames.NicifyVariableName(enumValue.ToString()) : enumValue.ToString()); } } public static IEnumerable GetEnumOptions() { return GetEnumOptions(false); } public static IEnumerable GetEnumOptionsNicified() { return GetEnumOptions(true); } } }