Beispiel #1
0
 public CustomInput(string group, string action, int mouseButton)
 {
     this.group       = group;
     this.action      = action;
     this.inputType   = CustomInputType.MouseButton;
     this.mouseButton = mouseButton;
 }
Beispiel #2
0
 public CustomInput(string group, string action, string axis)
 {
     this.group     = group;
     this.action    = action;
     this.inputType = CustomInputType.Axis;
     this.axis      = axis;
 }
Beispiel #3
0
 public CustomInput(string group, string action, KeyCode key)
 {
     this.group     = group;
     this.action    = action;
     this.inputType = CustomInputType.Key;
     this.key       = key;
 }
Beispiel #4
0
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            int numItems = 5;

            CustomInputType inputType = (CustomInputType)property.FindPropertyRelative("inputType").intValue;

            if (inputType == CustomInputType.Axis)
            {
                numItems = 6;
            }
            return(itemHeight * numItems + borderHeight * 2 + spacing * (numItems - 1));
        }
Beispiel #5
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(position, label, property);

            GUI.Box(position, GUIContent.none);

            Rect nextPropertyRect = new Rect(position.x, position.y + borderHeight, position.width, itemHeight);

            EditorGUI.LabelField(nextPropertyRect, label);

            nextPropertyRect = new Rect(position.x, position.y + borderHeight + itemHeight + spacing, position.width, itemHeight);
            EditorGUI.PropertyField(nextPropertyRect, property.FindPropertyRelative("group"));

            nextPropertyRect = new Rect(position.x, position.y + borderHeight + itemHeight * 2 + spacing * 2, position.width, itemHeight);
            EditorGUI.PropertyField(nextPropertyRect, property.FindPropertyRelative("action"));

            nextPropertyRect = new Rect(position.x, position.y + borderHeight + itemHeight * 3 + spacing * 3, position.width, itemHeight);
            EditorGUI.PropertyField(nextPropertyRect, property.FindPropertyRelative("inputType"));

            CustomInputType inputType = (CustomInputType)property.FindPropertyRelative("inputType").intValue;

            switch (inputType)
            {
            case CustomInputType.Key:

                nextPropertyRect = new Rect(position.x, position.y + borderHeight + itemHeight * 4 + spacing * 4, position.width, itemHeight);
                EditorGUI.PropertyField(nextPropertyRect, property.FindPropertyRelative("key"));
                break;

            case CustomInputType.MouseButton:

                nextPropertyRect = new Rect(position.x, position.y + borderHeight + itemHeight * 4 + spacing * 4, position.width, itemHeight);
                EditorGUI.PropertyField(nextPropertyRect, property.FindPropertyRelative("mouseButton"));
                break;

            case CustomInputType.Axis:

                nextPropertyRect = new Rect(position.x, position.y + borderHeight + itemHeight * 4 + spacing * 4, position.width, itemHeight);
                EditorGUI.PropertyField(nextPropertyRect, property.FindPropertyRelative("getAxisRaw"));

                nextPropertyRect = new Rect(position.x, position.y + borderHeight + itemHeight * 5 + spacing * 5, position.width, itemHeight);
                EditorGUI.PropertyField(nextPropertyRect, property.FindPropertyRelative("axis"));
                break;
            }

            EditorGUI.EndProperty();
        }