public void SetNodeGraph(NodeGraph nodeGraph) { Reset(); if (nodeGraph == null) { return; } m_nodeGraphSO = new SerializedObject(nodeGraph); m_graphPropertiesProp = m_nodeGraphSO.FindProperty(NodeGraph.GraphProperties_VarName); m_graphNameLabel.text = nodeGraph.name; m_graphObjectField.SetObject(nodeGraph); if (nodeGraph.GraphProperties.UseIMGUIPropertyDrawer) { m_imguiContainer.Bind(m_nodeGraphSO); m_graphPropertiesArea.Add(m_imguiContainer); } else { m_propertyField = new PropertyField(m_graphPropertiesProp); m_propertyField.Bind(m_nodeGraphSO); m_graphPropertiesArea.Add(m_propertyField); } m_blackboardView.SetNodeGraph(nodeGraph); }
static VisualElement BuildVectorEditor <T>(this IConstantEditorBuilder builder, IEditableVectorType <T> v) { var root = new VisualElement(); root.styleSheets.Add(AssetDatabase.LoadAssetAtPath <StyleSheet>(UICreationHelper.TemplatePath + "ConstantEditors.uss")); root.AddToClassList(v.UssClassName); if (v.Object != null) { var serializedObject = new SerializedObject(v.Object); foreach (var propertyName in v.PropertyNames) { SerializedProperty p = serializedObject.FindProperty(propertyName); var propertyField = new PropertyField(p); propertyField.RegisterCallback <ChangeEvent <T> >(new EventCallback <IChangeEvent>(builder.OnValueChanged)); root.Add(propertyField); } } else { foreach (var propertyLabel in v.PropertyLabels) { root.Add(v.MakePreviewField(propertyLabel)); } } return(root); }
public override VisualElement CreateInspectorGUI() { var container = new VisualElement(); var iterator = serializedObject.GetIterator(); if (!iterator.NextVisible(true)) { return(container); } while (iterator.NextVisible(false)) { var propertyField = new PropertyField(iterator.Copy()) { name = "PropertyField:" + iterator.propertyPath }; if (iterator.propertyPath == "m_Script" && serializedObject.targetObject != null) { propertyField.SetEnabled(false); } container.Add(propertyField); } container.Bind(serializedObject); return(container); }
private static void PopulateProperties(PropertyFieldUI ui, PropertyField field, DataProvider?dataProvider) { PopulateProperties(ui, field); ui.Property = field.Property; ui.DataCollection = dataProvider?.Collection; }
public static void Expose( PropertyField[] properties ) { GUILayoutOption[] emptyOptions = new GUILayoutOption[0]; EditorGUILayout.BeginVertical(emptyOptions); foreach(PropertyField field in properties) { EditorGUILayout.BeginHorizontal(emptyOptions); switch(field.Type) { case SerializedPropertyType.Integer: field.SetValue(EditorGUILayout.IntField(field.Name, (int)field.GetValue(), emptyOptions)); break; case SerializedPropertyType.Float: field.SetValue(EditorGUILayout.FloatField(field.Name, (float)field.GetValue(), emptyOptions)); break; case SerializedPropertyType.Boolean: field.SetValue(EditorGUILayout.Toggle(field.Name, (bool)field.GetValue(), emptyOptions)); break; case SerializedPropertyType.String: field.SetValue(EditorGUILayout.TextField(field.Name, (String)field.GetValue(), emptyOptions)); break; case SerializedPropertyType.Vector2: field.SetValue(EditorGUILayout.Vector2Field(field.Name, (Vector2)field.GetValue(), emptyOptions)); break; case SerializedPropertyType.Vector3: field.SetValue(EditorGUILayout.Vector3Field(field.Name, (Vector3)field.GetValue(), emptyOptions)); break; case SerializedPropertyType.Enum: field.SetValue(EditorGUILayout.EnumPopup(field.Name, (Enum)field.GetValue(), emptyOptions)); break; default: break; } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); }
public static PropertyField[] GetProperties( System.Object obj ) { List< PropertyField > fields = new List<PropertyField>(); PropertyInfo[] infos = obj.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance); foreach(PropertyInfo info in infos) { if(!(info.CanRead && info.CanWrite)) continue; object[] attributes = info.GetCustomAttributes(true); bool isExposed = false; foreach(object o in attributes) { if(o.GetType() == typeof(ExposePropertyAttribute)) { isExposed = true; break; } } if(!isExposed) continue; SerializedPropertyType type = SerializedPropertyType.Integer; if(PropertyField.GetPropertyType(info, out type)) { PropertyField field = new PropertyField(obj, info, type); fields.Add(field); } } return fields.ToArray(); }
public void it_faces_exceptions_projectFeatures_field_when_unauthorized() { string projectId = "_Root"; string featureId = "PROJECT_EXT_1"; PropertyField propertyField = PropertyField.WithFields(name: true, value: true, inherited: true); PropertiesField propertiesField = PropertiesField.WithFields(propertyField: propertyField); ProjectFeatureField projectFeatureField = ProjectFeatureField.WithFields(type: true, properties: propertiesField); try { m_client.Projects.GetFields(projectFeatureField.ToString()) .GetProjectFeatureByProjectFeature(projectId, featureId); } catch (HttpException e) { Console.WriteLine(e); Assert.That(e.ResponseStatusCode == HttpStatusCode.Forbidden); } catch (Exception e) { Assert.Fail("GetFields faced an unexpected exception", e); } }
public override VisualElement CreateInspectorGUI() { var root = new VisualElement(); var system = target as UIElementsEventSystem; var defaultSelection = system.sendIMGUIEvents ? m_EventGenerationChoices[1] : m_EventGenerationChoices[0]; inputEventsField = new PopupField <string>("Event Generation", m_EventGenerationChoices, defaultSelection); inputEventsField.RegisterValueChangedCallback((evt) => OnPopupValueChanged(evt)); root.Add(inputEventsField); var serializedProperty = serializedObject.FindProperty("m_SendNavigationEvents"); SendNavigationField = new PropertyField(serializedProperty); root.Add(SendNavigationField); //TODO: Group Navigation events parameters together in a foldout and toggle visibility when navigation is enabled //TODO: Group Input delay and repeat together and only show when sendInputEvents is selected. while (serializedProperty.Next(false)) { root.Add(new PropertyField(serializedProperty)); } inputEventsField.schedule.Execute(() => UpdatePopupFieldValues()).Every(100); UpdateNavigationFieldVisibility(); return(root); }
public override VisualElement CreatePropertyGUI(SerializedProperty property) { var container = new VisualElement(); var keyProperty = property.FindPropertyRelative("key"); var targetProperty = keyProperty.FindPropertyRelative("target"); var targetChoices = new List <Target> { Target.Global, Target.Item }; var targetField = new PopupField <Target>("Target", targetChoices, (Target)targetProperty.enumValueIndex); var keyField = new PropertyField(keyProperty.FindPropertyRelative("key")); var itemContainer = CreateItemContainer(property.FindPropertyRelative("item")); void SwitchDisplayItem(Target target) { itemContainer.SetVisibility(target == Target.Item); } targetField.RegisterValueChangedCallback(e => { targetProperty.enumValueIndex = (int)e.newValue; property.serializedObject.ApplyModifiedProperties(); SwitchDisplayItem(e.newValue); }); SwitchDisplayItem((Target)targetProperty.enumValueIndex); container.Add(targetField); container.Add(keyField); container.Add(itemContainer); return(container); }
public override VisualElement CreatePropertyGUI(SerializedProperty property) { var showMemberLabels = (attribute as InlineAttribute).ShowMemberLabels; var container = new VisualElement(); var childContainer = new VisualElement(); childContainer.AddToClassList(ChildrenUssClassName); if (!showMemberLabels) { var label = new FieldContainer(property.displayName, this.GetTooltip()); label.AddToClassList(LabelUssClassName); container.Add(label); } foreach (var child in property.Children()) { var field = new PropertyField(child); if (!showMemberLabels) { field.SetLabel(null); } childContainer.Add(field); } container.Add(childContainer); container.AddToClassList(UssClassName); container.AddStyleSheet(Configuration.ElementsPath, Stylesheet); return(container); }
private void GenerateListElements() { listContainer.Clear(); for (var i = 0; i < listProperty.arraySize; i++) { var elementIndex = i; var property = listProperty.GetArrayElementAtIndex(i); var rootElementContainer = elementTemplate.CloneTree(); rootElementContainer.styleSheets.Add(elementStyleSheet); rootElementContainer.Q <Label>("type-label").text = targetDatabase.EntityRepresentationResolvers[i].GetType().Name; var elementPropertyField = new PropertyField(property) { name = "element-property" }; elementPropertyField.BindProperty(property); rootElementContainer.Q("property-container").Insert(0, elementPropertyField); rootElementContainer.Q <Button>("delete-button").clicked += () => { listProperty.DeleteArrayElementAtIndex(elementIndex); serializedObject.ApplyModifiedProperties(); GenerateListElements(); }; listContainer.Add(rootElementContainer); } }
public static PropertyField[] GetProperties(UnityEngine.Object obj) { List <PropertyField> fields = new List <PropertyField>(); PropertyInfo[] propertyInfos = obj.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance); foreach (PropertyInfo info in propertyInfos) { if (!(info.CanRead && info.CanWrite)) { continue; } if (!AttributeUtil.HasAttribute <ExposePropertyAttribute>(info)) { continue; } SerializedPropertyType type; if (PropertyField.GetPropertyType(info, out type)) { PropertyField field = new PropertyField(obj, info, type); fields.Add(field); } } return(fields.ToArray()); }
public static VisualElement CreateScenarioEndingList(SerializedProperty listProperty, string label, bool useHeader = false) { var list = new Foldout { text = label }; var endingList = ((ScenarioEnding[])Enum.GetValues(typeof(ScenarioEnding))).ToList(); listProperty.arraySize = endingList.Count; listProperty.serializedObject.ApplyModifiedProperties(); for (var i = 0; i < endingList.Count; i++) { VisualElement listElem; if (useHeader) { list.Add(new Label(endingList[i].ToDisplayName()) { style = { unityFontStyleAndWeight = new StyleEnum <FontStyle>(FontStyle.Bold) } }); listElem = new PropertyField(listProperty.GetArrayElementAtIndex(i)); } else { listElem = new PropertyField(listProperty.GetArrayElementAtIndex(i), endingList[i].ToDisplayName()); } list.Add(listElem); } return(list); }
static SerializedPropertyExtensions() { var createFieldFromPropertyMethod = typeof(PropertyField).GetMethod(_createFieldFromPropertyName, BindingFlags.Instance | BindingFlags.NonPublic); var createFieldFromPropertyParameters = createFieldFromPropertyMethod?.GetParameters(); if (createFieldFromPropertyMethod != null && createFieldFromPropertyMethod.HasSignature(typeof(VisualElement), typeof(SerializedProperty))) { _createFieldFromPropertyMethod = createFieldFromPropertyMethod; _createFieldFromPropertyInstance = new PropertyField(); } var gradientValueProperty = typeof(SerializedProperty).GetProperty(_gradientValueName, BindingFlags.Instance | BindingFlags.NonPublic); if (gradientValueProperty != null && gradientValueProperty.PropertyType == typeof(Gradient) && gradientValueProperty.CanRead && gradientValueProperty.CanWrite) { _gradientValueProperty = gradientValueProperty; } var hasVisibleChildFieldsMethod = typeof(EditorGUI).GetMethod(_hasVisibleChildFieldsName, BindingFlags.Static | BindingFlags.NonPublic); if (hasVisibleChildFieldsMethod != null && hasVisibleChildFieldsMethod.HasSignature(typeof(bool), typeof(SerializedProperty))) { _hasVisibleChildFieldsMethod = hasVisibleChildFieldsMethod; } if (_createFieldFromPropertyMethod == null || _gradientValueProperty == null || _hasVisibleChildFieldsMethod == null) { Debug.LogError(_changedInternalsError); } }
private VisualElement GetParameterField(SerializedProperty property) { SerializedProperty index = property.FindPropertyRelative("index"); if (index.intValue >= parametersIndex.Count) { index.intValue = parametersIndex.Count - 1; serializedObject.ApplyModifiedProperties(); } PropertyField propField = new PropertyField(property); propField.RegisterCallback <GeometryChangedEvent>(evt => { propField.Q <Foldout>().style.display = DisplayStyle.None; }); Label label = new Label(property.displayName); propField.Add(label); //PopupField<int> popupField = new PopupField<int>(property.displayName, parametersIndex, index.intValue, FormatItem, FormatItem); //popupField.BindProperty(index); //popupField.Q<VisualElement>(className: "unity-popup-field__input").SetEnabled(property.FindPropertyRelative("enabled").boolValue); //Toggle enableToggle = new Toggle(string.Empty); //popupField.Insert(1, enableToggle); //enableToggle.BindProperty(property.FindPropertyRelative("enabled")); //enableToggle.RegisterValueChangedCallback(x => //{ // popupField.Q<VisualElement>(className: "unity-popup-field__input").SetEnabled(x.newValue); //}); return(propField); }
void CreatePropertyFields() { m_PropertiesContainer.Clear(); if (parameter is CategoricalParameterBase) { CreateCategoricalParameterFields(); return; } var nextSiblingProperty = m_SerializedProperty.Copy(); nextSiblingProperty.NextVisible(false); var currentProperty = m_SerializedProperty.Copy(); if (currentProperty.NextVisible(true)) { do { if (SerializedProperty.EqualContents(currentProperty, nextSiblingProperty)) { break; } var propertyField = new PropertyField(currentProperty.Copy()); propertyField.Bind(currentProperty.serializedObject); m_PropertiesContainer.Add(propertyField); } while (currentProperty.NextVisible(false)); } }
public override VisualElement CreatePropertyGUI(SerializedProperty property) { var container = new VisualElement(); var keyProperty = property.FindPropertyRelative("key"); var targetProperty = property.FindPropertyRelative("target"); var itemProperty = property.FindPropertyRelative("item"); var itemContainer = new PropertyField(itemProperty); void SwitchDisplayItem(GimmickTarget target) { itemContainer.SetVisibility(target == GimmickTarget.Item); } SwitchDisplayItem((GimmickTarget)targetProperty.enumValueIndex); var targetField = EnumField.Create <GimmickTarget>(targetProperty.displayName, targetProperty, SwitchDisplayItem); var keyField = new PropertyField(keyProperty); container.Add(targetField); container.Add(keyField); container.Add(itemContainer); return(container); }
private void Init() { var scrollView = new ScrollView(ScrollViewMode.Vertical); rootVisualElement.Add(scrollView); var so = new SerializedObject(_library); var list = new MoldsReorderableList(so, so.FindProperty("molds")); list.applyButtonClickedEvent += i => OnApplyButtonClicked(_library.molds[i]); scrollView.Add(list); var moldInspector = new VisualElement(); var moldProp = new PropertyField(); moldProp.Bind(so); list.OnSelectCallback += UpdateMoldInspector; void UpdateMoldInspector(ReorderableList l) { moldProp.bindingPath = $"molds.Array.data[{l.index}]"; moldProp.Bind(so); moldProp.Q <Foldout>().value = true; } moldInspector.Add(moldProp); scrollView.Add(moldInspector); }
public InlineField(SerializedProperty property, bool showMemberLabels) { var childContainer = new VisualElement(); childContainer.AddToClassList(ChildrenUssClassName); if (!showMemberLabels) { var label = new FieldContainer(property.displayName); label.AddToClassList(LabelUssClassName); Add(label); } foreach (var child in property.Children()) { var field = new PropertyField(child); if (!showMemberLabels) { field.SetFieldLabel(null); } childContainer.Add(field); } Add(childContainer); AddToClassList(UssClassName); this.AddStyleSheet(Stylesheet); }
private void DisplayAnimationPropertyField(SerializedObject _targetState) { PropertyField animProp = new PropertyField(_targetState.FindProperty("m_combatAnim").FindPropertyRelative("m_animClip")); animProp.Bind(_targetState); ContainerElement.Q <VisualElement>("state-details-area").Add(animProp); }
void BuildDefaultSection(VisualElement container) { var iterator = serializedObject.GetIterator(); if (iterator.NextVisible(true)) { do { var propertyField = new PropertyField(iterator.Copy()) { name = "PropertyField:" + iterator.propertyPath }; propertyField.BindProperty(iterator.Copy()); if (iterator.propertyPath == nameof(ViewerReflectBootstrapper.Asset)) { propertyField.RegisterValueChangeCallback(OnAssignedAssetChanged); } if (iterator.propertyPath == "m_Script" && serializedObject.targetObject != null) { propertyField.SetEnabled(false); } container.Add(propertyField); }while (iterator.NextVisible(false)); } }
public static VisualElement CreateDefault(SerializedObject serializedObject) { VisualElement container = new VisualElement(); SerializedProperty iterator = serializedObject.GetIterator(); VisualElement propertyField; if (iterator.NextVisible(true)) { do { if (iterator.propertyPath == "m_Script" && serializedObject.targetObject != null) { propertyField = CreateScriptReadonlyField(iterator); } else { propertyField = new PropertyField(iterator.Copy()) { name = $"PropertyField:{iterator.propertyPath}" }; } container.Add(propertyField); }while (iterator.NextVisible(false)); } return(container); }
private VisualElement MakeItem(SerializedProperty prop, string prop_path, int index) { Debug.Log("MAKING ITEM!"); var container = new VisualElement(); container.style.flexDirection = FlexDirection.Row; container.style.flexGrow = new StyleFloat(1.0f); var remove_button = new Button(() => { prop.DeleteArrayElementAtIndex(index); prop.serializedObject.ApplyModifiedProperties(); }); remove_button.text = "-"; remove_button.style.color = new StyleColor(UnityEngine.Color.white); remove_button.style.backgroundColor = new StyleColor(UnityEngine.Color.red); remove_button.style.marginBottom = new StyleLength(0.0); remove_button.style.marginLeft = new StyleLength(0.0); remove_button.style.marginTop = new StyleLength(0.0); remove_button.style.marginRight = new StyleLength(0.0); remove_button.style.borderBottomLeftRadius = new StyleLength(0.0); remove_button.style.borderTopLeftRadius = new StyleLength(0.0); remove_button.style.borderTopRightRadius = new StyleLength(0.0); remove_button.style.borderBottomRightRadius = new StyleLength(0.0); container.Add(remove_button); var pf = new PropertyField(prop.GetArrayElementAtIndex(index), ""); pf.style.flexGrow = new StyleFloat(1.0f); container.Add(pf); return(container); }
void CreatePropertyFields() { m_InspectorPropertiesContainer = m_Root.Q <VisualElement>("inspector-properties"); m_InspectorPropertiesContainer.Clear(); var iterator = m_SerializedObject.GetIterator(); var foundProperties = false; if (iterator.NextVisible(true)) { do { if (iterator.name == "m_Script") { // Skip this property } else if (iterator.name == "constants") { m_ConstantsProperty = iterator.Copy(); } else { foundProperties = true; var propertyField = new PropertyField(iterator.Copy()); propertyField.Bind(m_SerializedObject); m_InspectorPropertiesContainer.Add(propertyField); } } while (iterator.NextVisible(false)); } if (!foundProperties) { m_InspectorPropertiesContainer.style.display = new StyleEnum <DisplayStyle>(DisplayStyle.None); } }
public static void FillDefaultInspector(VisualElement container, SerializedObject serializedObject, bool hideScript) { SerializedProperty property = serializedObject.GetIterator(); if (property.NextVisible(true)) // Expand first child. { do { if (property.propertyPath == "m_Script" && hideScript) { continue; } var field = new PropertyField(property); field.name = "PropertyField:" + property.propertyPath; if (property.propertyPath == "m_Script" && serializedObject.targetObject != null) { field.SetEnabled(false); } container.Add(field); } while (property.NextVisible(false)); } }
void CreatePropertyFields() { m_RangeProperty = null; m_Properties.Clear(); var currentProperty = m_Property.Copy(); var nextSiblingProperty = m_Property.Copy(); nextSiblingProperty.NextVisible(false); if (currentProperty.NextVisible(true)) { do { if (SerializedProperty.EqualContents(currentProperty, nextSiblingProperty)) { break; } if (currentProperty.name == "<baseSeed>k__BackingField") { m_Properties.Add(new RandomSeedField(currentProperty.Copy())); } else if (currentProperty.type == "FloatRange") { m_RangeProperty = currentProperty.Copy(); m_Properties.Add(new FloatRangeElement(m_RangeProperty)); } else { var propertyField = new PropertyField(currentProperty.Copy()); propertyField.Bind(m_Property.serializedObject); m_Properties.Add(propertyField); } }while (currentProperty.NextVisible(false)); } }
protected virtual void AddInputPort(Port port) { var view = PortView.Create(port, port.type, m_ConnectorListener); // If we want to display an inline editable field as part // of the port, create a new PropertyField and bind it. if (port.fieldName != null) { var prop = m_SerializedNode.FindPropertyRelative(port.fieldName); if (prop != null) { var field = new PropertyField(prop, " "); field.Bind(m_SerializedNode.serializedObject); field.RegisterCallback((FocusOutEvent e) => OnPropertyChange()); var container = new VisualElement(); container.AddToClassList("property-field-container"); container.Add(field); view.SetEditorField(container); } } inputs.Add(view); inputContainer.Add(view); }
public VisualElement GetParameterSettingsField(ExposedParameter parameter, Action <object> valueChangedCallback) { serializedObject.Update(); int propIndex = FindPropertyIndex(parameter); var serializedParameter = serializedParameters.GetArrayElementAtIndex(propIndex); serializedParameter.managedReferenceValue = exposedParameterObject.parameters[propIndex]; var serializedSettings = serializedParameter.FindPropertyRelative(nameof(ExposedParameter.settings)); serializedSettings.managedReferenceValue = exposedParameterObject.parameters[propIndex].settings; var settingsField = new PropertyField(serializedSettings); settingsField.Bind(serializedObject); VisualElement view = new VisualElement(); view.Add(settingsField); // TODO: see if we can replace this with an event oldParameterSettings[parameter] = parameter.settings; view.Add(new IMGUIContainer(() => { if (oldParameterSettings.TryGetValue(parameter, out var settings)) { if (!settings.Equals(parameter.settings)) { valueChangedCallback(parameter.settings); } } oldParameterSettings[parameter] = parameter.settings; })); return(view); }
static void CreateManagedItem(ReorderableList list, int index, VisualElement root) { const float leftMargin = 14; // Space for foldout arrow var element = list.ListProperty.GetArrayElementAtIndex(index); var label = ManagedReferenceUtility.GetDisplayName(element.managedReferenceFullTypename); if (!element.hasVisibleChildren) { root.Add(new Label(label.text) { style = { paddingLeft = leftMargin } }); } else { var propEditor = new PropertyField(element, label.text) { style = { paddingLeft = leftMargin } }; propEditor.BindProperty(list.ListProperty.serializedObject); propEditor.SetEnabled(!IsReadOnly(element)); propEditor.style.paddingLeft = 14; root.Add(propEditor); } }
public static PropertyField[] GetProperties(object obj) { var fields = new List <PropertyField>(); PropertyInfo[] infos = obj.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance); foreach (var info in infos) { if (!(info.CanRead && info.CanWrite)) { continue; } var attributes = info.GetCustomAttributes(true); if (attributes.All(o => o.GetType() != typeof(ExposePropertyAttribute))) { continue; } SerializedPropertyType type = SerializedPropertyType.Integer; if (PropertyField.GetPropertyType(info, out type)) { var field = new PropertyField(obj, info, type); fields.Add(field); } } return(fields.ToArray()); }
private void DrawParameterSpecificField(VisualElement vis, AnimatorControllerParameterType animatorParameterType) { // ------------- PropertyField propertyField; switch (animatorParameterType) { case AnimatorControllerParameterType.Bool: propertyField = new PropertyField(_boolValue); propertyField.tooltip = "..."; break; case AnimatorControllerParameterType.Float: propertyField = new PropertyField(_floatValue); propertyField.tooltip = "..."; break; case AnimatorControllerParameterType.Int: propertyField = new PropertyField(_intValue); propertyField.tooltip = "..."; break; default: return; } vis.Add(propertyField); // ------------- }
public static PropertyField CreatePropertyField(this SerializedObject serializedObject, string propertyName, string label = "") { SerializedProperty property = serializedObject.FindProperty(propertyName); PropertyField field = new PropertyField(property, label); return(field); }
public static void Expose(PropertyField[] properties) { var emptyOptions = new GUILayoutOption[0]; EditorGUILayout.BeginVertical(emptyOptions); foreach (PropertyField field in properties) { GUI.enabled = field.Info.CanWrite; EditorGUILayout.BeginHorizontal(emptyOptions); if (field.Type == SerializedPropertyType.Integer) { var oldValue = (int)field.GetValue(); var newValue = EditorGUILayout.IntField(field.Name, oldValue, emptyOptions); if (oldValue != newValue) field.SetValue(newValue); } else if (field.Type == SerializedPropertyType.Float) { var oldValue = (float)field.GetValue(); var newValue = EditorGUILayout.FloatField(field.Name, oldValue, emptyOptions); if (oldValue != newValue) field.SetValue(newValue); } else if (field.Type == SerializedPropertyType.Boolean) { var oldValue = (bool)field.GetValue(); var newValue = EditorGUILayout.Toggle(field.Name, oldValue, emptyOptions); if (oldValue != newValue) field.SetValue(newValue); } else if (field.Type == SerializedPropertyType.String) { var oldValue = (string)field.GetValue(); var newValue = EditorGUILayout.TextField(field.Name, oldValue, emptyOptions); if (oldValue != newValue) field.SetValue(newValue); } else if (field.Type == SerializedPropertyType.Vector2) { var oldValue = (Vector2)field.GetValue(); var newValue = EditorGUILayout.Vector2Field(field.Name, oldValue, emptyOptions); if (oldValue != newValue) field.SetValue(newValue); } else if (field.Type == SerializedPropertyType.Vector3) { var oldValue = (Vector3)field.GetValue(); var newValue = EditorGUILayout.Vector3Field(field.Name, oldValue, emptyOptions); if (oldValue != newValue) field.SetValue(newValue); } else if (field.Type == SerializedPropertyType.Enum) { var oldValue = (Enum)field.GetValue(); var newValue = EditorGUILayout.EnumPopup(field.Name, oldValue, emptyOptions); if (oldValue != newValue) field.SetValue(newValue); } else if (field.Type == SerializedPropertyType.ObjectReference) { UnityEngine.Object oldValue = (UnityEngine.Object)field.GetValue(); UnityEngine.Object newValue = EditorGUILayout.ObjectField(field.Name, oldValue, field.Info.PropertyType, emptyOptions); if (oldValue != newValue) field.SetValue(newValue); } EditorGUILayout.EndHorizontal(); GUI.enabled = true; } EditorGUILayout.EndVertical(); }