public InteractionsVariableInspector(SerializedProperty property) { var container = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>("Assets/UI/Resources/InteractionVariable.uxml").CloneTree(); type_selector = container.Q <EnumField>("type-selector"); var type_prop = property.FindPropertyRelative("var_type"); type_selector.bindingPath = type_prop.propertyPath; type_selector.RegisterValueChangedCallback((ChangeEvent <System.Enum> evnt) => { if (evnt.newValue is InteractionsVariableType var_type) { this.var_type = var_type; UpdateDisplay(); } }); name_field = container.Q <TextField>("name-field"); name_field.bindingPath = property.FindPropertyRelative("name").propertyPath; int_selector = container.Q <IntegerField>("int-selector"); int_selector.bindingPath = property.FindPropertyRelative("int_val").propertyPath; float_selector = container.Q <FloatField>("float-selector"); float_selector.bindingPath = property.FindPropertyRelative("float_val").propertyPath; vec2_selector = container.Q <Vector2Field>("vec2-selector"); vec2_selector.bindingPath = property.FindPropertyRelative("vec2_val").propertyPath; vec3_selector = container.Q <Vector3Field>("vec3-selector"); vec3_selector.bindingPath = property.FindPropertyRelative("vec3_val").propertyPath; bool_selector = container.Q <Toggle>("bool-selector"); bool_selector.bindingPath = property.FindPropertyRelative("bool_val").propertyPath; string_selector = container.Q <TextField>("string-selector"); string_selector.bindingPath = property.FindPropertyRelative("string_val").propertyPath; interaction_selector = container.Q <PropertyField>("interaction-selector"); interaction_selector.bindingPath = property.FindPropertyRelative("graph_val").propertyPath; animator_selector = container.Q <PropertyField>("animator-selector"); animator_selector.bindingPath = property.FindPropertyRelative("animator_val").propertyPath; var_type = InteractionsVariableTypeExtensions.TypesByIndex[type_prop.enumValueIndex]; UpdateDisplay(); Add(container); }
private DisplayStyle MatchesType(InteractionsVariableType ref_type) { return(ref_type == var_type ? DisplayStyle.Flex : DisplayStyle.None); }