static VisualElement CreateConstantValuePropertyGUI(SerializedProperty property) { Assert.AreEqual(property.type, nameof(ConstantValue)); var container = new VisualElement { style = { flexDirection = new StyleEnum <FlexDirection>(FlexDirection.Row), flexGrow = new StyleFloat(9) } }; var boolValueProperty = property.FindPropertyRelative("boolValue"); Assert.AreEqual(boolValueProperty.propertyType, SerializedPropertyType.Boolean); var boolValueField = new Toggle { bindingPath = boolValueProperty.propertyPath, style = { flexGrow = new StyleFloat(9) } }; boolValueField.Bind(boolValueProperty.serializedObject); container.Add(boolValueField); var floatValueProperty = property.FindPropertyRelative("floatValue"); Assert.AreEqual(floatValueProperty.propertyType, SerializedPropertyType.Float); var floatValueField = new FloatField { bindingPath = floatValueProperty.propertyPath, style = { flexGrow = new StyleFloat(9) } }; floatValueField.Bind(floatValueProperty.serializedObject); container.Add(floatValueField); var integerValueProperty = property.FindPropertyRelative("integerValue"); Assert.AreEqual(integerValueProperty.propertyType, SerializedPropertyType.Integer); var integerValueField = new IntegerField { bindingPath = integerValueProperty.propertyPath, style = { flexGrow = new StyleFloat(9) } }; integerValueField.Bind(integerValueProperty.serializedObject); container.Add(integerValueField); var typeProperty = property.FindPropertyRelative("type"); var typeChoices = new List <ParameterType> { ParameterType.Bool, ParameterType.Float, ParameterType.Integer }; var currentType = (ParameterType)typeProperty.intValue; var selectingTarget = typeChoices.Contains(currentType) ? currentType : typeChoices[0]; var typeField = EnumField.Create(typeProperty, typeChoices, selectingTarget, SwitchField); container.Insert(0, typeField); void SwitchField(ParameterType type) { boolValueField.SetVisibility(type == ParameterType.Bool); floatValueField.SetVisibility(type == ParameterType.Float); integerValueField.SetVisibility(type == ParameterType.Integer); } SwitchField(selectingTarget); return(container); }