Пример #1
0
    public override void OnGUI(Rect position, SerializedProperty a_Property, GUIContent a_Label)
    {
        position.height = EditorHelp.c_LineHeight;
        EditorGUI.BeginProperty(position, a_Label, a_Property);

        SerializedProperty foldOutProperty = a_Property.FindPropertyRelative("m_IsFoldingOut");
        SerializedProperty prefabProperty  = a_Property.FindPropertyRelative("m_AbilityModulePrefab");
        AbilityModule      prefab          = null;
        string             nameString      = "Ability slot empty";

        if (prefabProperty.objectReferenceValue != null)
        {
            prefab     = prefabProperty.objectReferenceValue as AbilityModule;
            nameString = prefab.GetName();
        }
        foldOutProperty.boolValue = EditorGUI.Foldout(position, foldOutProperty.boolValue, nameString, true);

        Rect pos = position;

        if (foldOutProperty.boolValue)
        {
            EditorGUI.indentLevel++;
            EditorHelp.PropertyDrawerLineWithVar(a_Property, "m_AbilityModulePrefab", ref pos, "", "Prefab");
            if (prefabProperty.objectReferenceValue != null)
            {
                if (EditorHelp.PropertyDrawerButton("Edit", ref pos))
                {
                    Selection.activeGameObject = prefab.gameObject;
                }
            }
            EditorGUI.indentLevel--;
        }

        EditorGUI.EndProperty();
    }
Пример #2
0
    public override void OnGUI(Rect position, SerializedProperty a_Property, GUIContent a_Label)
    {
        position.height = EditorHelp.c_LineHeight;
        EditorGUI.BeginProperty(position, a_Label, a_Property);

        SerializedProperty foldOutProperty = a_Property.FindPropertyRelative("m_IsFoldingOut");
        string             nameString      = a_Property.FindPropertyRelative("m_Name").stringValue;

        if (nameString == "")
        {
            nameString = "<InputName missing>";
        }

        foldOutProperty.boolValue = EditorGUI.Foldout(position, foldOutProperty.boolValue, nameString, true);

        Rect pos = position;

        if (foldOutProperty.boolValue)
        {
            EditorGUI.indentLevel++;
            EditorHelp.PropertyDrawerLineWithVar(a_Property, "m_Name", ref pos, "Name of this input, as referenced in code");
            EditorHelp.PropertyDrawerLineWithVar(a_Property, "m_InputType", ref pos, "Is this input a button (or key), or directional (analogue stick, arrow keys, WASD)?");

            InputElement.InputType type = (InputElement.InputType)a_Property.FindPropertyRelative("m_InputType").enumValueIndex;
            switch (type)
            {
            case InputElement.InputType.Button:
            {
                EditorHelp.PropertyDrawerLineWithVar(a_Property, "m_UnityInputType", ref pos, "Is this a button, or can it be triggered by an axis as well (triggers on a gamepad for example)");
                if (a_Property.FindPropertyRelative("m_UnityInputType").enumValueIndex != 0)
                {
                    EditorHelp.PropertyDrawerLineWithVar(a_Property, "m_UnityAxisRecognition", ref pos, "If this button can be triggered by an axis, should it trigger if the axis value is: positive only, negative only, or not zero");
                }
                EditorHelp.PropertyDrawerLineWithVar(a_Property, "m_ButtonName", ref pos, "In Unity's input manager, what is the name of the button/axis that this input uses?");
            }
            break;

            case InputElement.InputType.Direction:
            {
                EditorHelp.PropertyDrawerLineWithVar(a_Property, "m_HorizontalAxisName", ref pos, "In Unity's input manager, what is the name of the axis that this input uses for its horizontal value?");
                EditorHelp.PropertyDrawerLineWithVar(a_Property, "m_VerticalAxisName", ref pos, "In Unity's input manager, what is the name of the axis that this input uses for its vertical value?");
                EditorHelp.PropertyDrawerLineWithVar(a_Property, "m_DirectionThreshold", ref pos, "In the case of analogue input, how far should the input be pushed before a direction is recognized? For example: how far should an analogue stick be pulled down before it registers as a crouch command");
            }
            break;
            }
            EditorGUI.indentLevel--;
        }

        EditorGUI.EndProperty();
    }