Exemplo n.º 1
0
        public static bool GetButtonUp(string axis)
        {
            bool input = false;

            Joycon joycon = GetDevice(axis);

            if (joycon != null)
            {
                input = JoyconBinding.ResolveAxis(axis).GetButtonUp(joycon);
            }

            return(input ? true : Input.GetButtonUp(JoyconBinding.ResolveName(axis, joycon)));
        }
Exemplo n.º 2
0
        public static Joycon GetDevice(string axis)
        {
            Joycon joycon = JoyconController.First;

            if (JoyconBinding.IsLeftAxis(axis))
            {
                joycon = JoyconController.GetLeftOrFirst();
            }
            else if (JoyconBinding.IsRightAxis(axis))
            {
                joycon = JoyconController.GetRightOrFirst();
            }

            return(joycon);
        }
Exemplo n.º 3
0
        public static float GetAxis(string axis)
        {
            float input = 0f;

            Joycon joycon = GetDevice(axis);

            if (joycon != null)
            {
                input += JoyconBinding.ResolveAxis(axis).GetAxis(joycon);
            }

            input += Input.GetAxis(JoyconBinding.ResolveName(axis, joycon));

            return(Mathf.Clamp(input, -1f, 1f));
        }
Exemplo n.º 4
0
        public void OnEnable()
        {
            this.me = (JoyconBinding)base.target;
            this.schemesProperty = base.serializedObject.FindProperty("schemes");
            this.schemesList     = new ReorderableList(serializedObject, this.schemesProperty, true, true, true, true);
            this.schemesList.drawHeaderCallback = (Rect rect) => {
                Rect column = rect;
                column.width *= 0.3333f;

                EditorGUI.LabelField(column, "Name");

                column.x += column.width;

                EditorGUI.LabelField(column, "Type");

                column.x += column.width;

                EditorGUI.LabelField(column, "Button");
            };
            this.schemesList.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => {
                SerializedProperty element = this.schemesList.serializedProperty.GetArrayElementAtIndex(index);
                SerializedProperty name    = element.FindPropertyRelative("name");
                SerializedProperty axis    = element.FindPropertyRelative("axis");
                SerializedProperty button  = element.FindPropertyRelative("button");

                Rect column = rect;
                column.height = rect.height * 0.75f;
                column.width *= 0.3333f;

                EditorGUI.PropertyField(column, name, new GUIContent());

                column.x += column.width;

                EditorGUI.PropertyField(column, axis, new GUIContent());

                column.x += column.width;

                using (new EditorGUI.DisabledScope(axis.intValue > 0))
                    EditorGUI.PropertyField(column, button, new GUIContent());
            };

            this.size = this.schemesProperty.arraySize;
        }