Example #1
0
        // Add joystick axis input bindings to InputManager
        // See OpenVR/Oculus left/right controllers mapping at
        // https://docs.unity3d.com/Manual/OpenVRControllers.html
        private static void EnforceInputManagerBindings()
        {
            try
            {
                var inputSettings = AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/InputManager.asset");
                if (inputSettings == null || inputSettings.Length <= 0)
                {
                    return;
                }

                var serializedInputSettings = new SerializedObject(inputSettings);

                var axisObj = new Axis();
                for (int i = 0, imax = UnityEngineVRModule.GetUnityAxisCount(); i < imax; ++i)
                {
                    axisObj.name = UnityEngineVRModule.GetUnityAxisNameByIndex(i);
                    axisObj.axis = UnityEngineVRModule.GetUnityAxisIdByIndex(i) - 1;
                    BindAxis(serializedInputSettings, axisObj);
                }

                EditorApplication.update -= EnforceInputManagerBindings;
            }
            catch (Exception e)
            {
                Debug.LogError(e + " Failed to apply Vive Input Utility input manager bindings.");
            }
        }
 private static void EnforceInputManagerBindings()
 {
     try
     {
         var axisObj = new Axis();
         for (int i = 0, imax = UnityEngineVRModule.GetUnityAxisCount(); i < imax; ++i)
         {
             axisObj.name = UnityEngineVRModule.GetUnityAxisNameByIndex(i);
             axisObj.axis = UnityEngineVRModule.GetUnityAxisIdByIndex(i) - 1;
             BindAxis(axisObj);
         }
     }
     catch
     {
         Debug.LogError("Failed to apply Vive Input Utility input manager bindings.");
     }
 }