Exemplo n.º 1
0
        public static void SeedInputs(UnityAxisBasedVRInputManager manager)
        {
            var axisList                = new List <InputAxis>();
            var inputManagerAsset       = UnityEditor.AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/InputManager.asset")[0];
            var serializedObject        = new UnityEditor.SerializedObject(inputManagerAsset);
            var inputManagerCurrentData = serializedObject.FindProperty("m_Axes");

            /// this part is done in the most stuoid way possible but I couldn;t figure another way of doing it
            #region populating input
            List <InputAxis> inputAxes = new List <InputAxis>();
            switch (manager.type)
            {
            case ControllerType.Normal:
                inputAxes = new List <InputAxis>
                {
                    new InputAxis()
                    {
                        name            = manager.LeftTrigger,
                        descriptiveName = "Device trigger axis",
                        axis            = 9,
                        type            = 2
                    },
                    new InputAxis()
                    {
                        name            = manager.LeftGrip,
                        descriptiveName = "Device grip axis",
                        axis            = 11,
                        type            = 2,
                    },
                    new InputAxis()
                    {
                        name            = manager.LeftThumb,
                        descriptiveName = "Device thumb proximity touch axis",
                        dead            = 0.19f,
                        axis            = 15,
                        type            = 2,
                    },
                    new InputAxis()
                    {
                        name            = manager.RightTrigger,
                        descriptiveName = "Device trigger axis",
                        axis            = 10,
                        type            = 2,
                    },
                    new InputAxis()
                    {
                        name            = manager.RightGrip,
                        descriptiveName = "Device grip axis",
                        axis            = 12,
                        type            = 2,
                    },
                    new InputAxis()
                    {
                        name            = manager.RightThumb,
                        descriptiveName = "Device thumb proximity touch axis",
                        dead            = 0.19f,
                        axis            = 16,
                        type            = 2,
                    }
                };
                break;

            case ControllerType.Knuckles:
                inputAxes = new List <InputAxis>
                {
                    new InputAxis()
                    {
                        name            = manager.LeftIndex,
                        descriptiveName = "Left Index Finger for a Knuckles Style controller",
                        axis            = 21,
                        type            = 2,
                    },
                    new InputAxis()
                    {
                        name            = manager.LeftMiddle,
                        descriptiveName = "Left Middle Finger for a Knuckles Style controller",
                        axis            = 23,
                        type            = 2,
                    },
                    new InputAxis()
                    {
                        name            = manager.LeftRing,
                        descriptiveName = "Left Ring Finger for a Knuckles Style controller",
                        axis            = 25,
                        type            = 2,
                    },
                    new InputAxis()
                    {
                        name            = manager.LeftPinky,
                        descriptiveName = "Left Pinky Finger for a Knuckles Style controller",
                        axis            = 27,
                        type            = 2,
                    },
                    new InputAxis()
                    {
                        name            = manager.LeftThumb,
                        descriptiveName = "Device thumb proximity touch axis",
                        dead            = 0.19f,
                        axis            = 15,
                        type            = 2,
                    },
                    new InputAxis()
                    {
                        name            = manager.RightIndex,
                        descriptiveName = "Right Index Finger for a Knuckles Style controller",
                        axis            = 22,
                        type            = 2,
                    },
                    new InputAxis()
                    {
                        name            = manager.RightMiddle,
                        descriptiveName = "Right Middle Finger for a Knuckles Style controller",
                        axis            = 24,
                        type            = 2,
                    },
                    new InputAxis()
                    {
                        name            = manager.RightRing,
                        descriptiveName = "Right Ring Finger for a Knuckles Style controller",
                        axis            = 26,
                        type            = 2,
                    },
                    new InputAxis()
                    {
                        name            = manager.RightPinky,
                        descriptiveName = "Right Pinky Finger for a Knuckles Style controller",
                        axis            = 28,
                        type            = 2,
                    },
                    new InputAxis()
                    {
                        name            = manager.RightThumb,
                        descriptiveName = "Device thumb proximity touch axis",
                        dead            = 0.19f,
                        axis            = 16,
                        type            = 2,
                    }
                };
                break;

            default:
                break;
            }

            for (int i = 0; i < inputAxes.Count; i++)
            {
                if (!ElementExsists(inputAxes[i].name, inputManagerCurrentData))
                {
                    AddAxe(inputAxes[i], ref inputManagerCurrentData);
                }
            }

            #endregion

            serializedObject.ApplyModifiedProperties();
        }
Exemplo n.º 2
0
 private void OnEnable()
 {
     manager = (UnityAxisBasedVRInputManager)target;
 }