public override VisualElement CreatePropertyGUI(SerializedProperty property) { if (property.propertyType == SerializedPropertyType.String) { var comboBox = new ComboBoxField(); void options() { var scenes = new List <string>(); for (var i = 0; i < EditorSceneManager.sceneCountInBuildSettings; i++) { var scene = EditorSceneManager.GetSceneByBuildIndex(i); scenes.Add(scene.name); } comboBox.Options = scenes; } var action = new Action(options); action.Invoke(); comboBox.schedule.Execute(action).Every(100); return(comboBox.ConfigureProperty(property)); } else { Debug.LogErrorFormat(_invalidTypeError, property.propertyPath); return(new FieldContainer(property.displayName)); } }
public override VisualElement CreatePropertyGUI(SerializedProperty property) { if (property.propertyType == SerializedPropertyType.String) { var comboBoxAttribute = attribute as ComboBoxAttribute; var comboBox = new ComboBoxField(); void options(IEnumerable <string> value) => comboBox.Options = value.ToList(); if (!ReflectionHelper.SetupValueSourceCallback(comboBoxAttribute.OptionsSource, fieldInfo.DeclaringType, property, comboBox, comboBoxAttribute.Options, comboBoxAttribute.AutoUpdate, options)) { Debug.LogWarningFormat(_invalidOptionsError, property.propertyPath, comboBoxAttribute.OptionsSource); } return(comboBox.ConfigureProperty(property)); } else { Debug.LogErrorFormat(_invalidTypeError, property.propertyPath); return(new FieldContainer(property.displayName)); } }