private void EnumChanged(ChangeEvent <Enum> _event) { m_ValueField.RemoveFromHierarchy(); ConfiguratorValueType newValue = (ConfiguratorValueType)_event.newValue; m_ValueField = ConfiguratorTypeConverter.CreateFieldBasedOnType(newValue, m_WorldStateDescription.Value, "Value", ValueFieldChanged); m_ValueField.AddToClassList("desiredValue"); hierarchy.Add(m_ValueField); }
protected void Init() { AddToClassList(USS_CLASS_NAME); AddToClassList("rounded"); m_KeyField = new TextField("World State") { value = m_WorldStateDescription.Key }; m_KeyField.tooltip = "The identifier of the world state."; m_KeyField.maxLength = 30; hierarchy.Add(m_KeyField); m_KeyField.RegisterCallback <ChangeEvent <string> >(KeyFieldChanged); hierarchy.Add(new Label("Desired Value")); ConfiguratorValueType?enumType = ConfiguratorTypeConverter.GetTypeFromObject(m_WorldStateDescription.Value); m_EnumFieldValueType = new EnumField("Type", enumType != null ? enumType : ConfiguratorValueType.BOOL) { tooltip = "Data type of the world state." }; m_EnumFieldValueType.AddToClassList("desiredValue"); hierarchy.Add(m_EnumFieldValueType); m_EnumFieldValueType.RegisterCallback <ChangeEvent <Enum> >(EnumChanged); m_ValueField = ConfiguratorTypeConverter.CreateFieldBasedOnType(enumType.Value, m_WorldStateDescription.Value, "Value", ValueFieldChanged); m_ValueField.tooltip = "Value of the world state."; m_ValueField.AddToClassList("desiredValue"); hierarchy.Add(m_ValueField); this.AddManipulator(new Clickable(() => OnMouseDown?.Invoke(this))); this.AddManipulator(new ContextualMenuManipulator(_menubuilder => { _menubuilder.menu.AppendAction("Delete", _dropDownMenuAction => OnDelete?.Invoke(this), DropdownMenuAction.Status.Normal); _menubuilder.menu.AppendAction("Duplicate", _dropDownMenuAction => OnDuplicate?.Invoke(this), DropdownMenuAction.Status.Normal); })); }