Beispiel #1
0
        public override bool InitAllControllers()
        {
            // SteamVR only works in windows.
            if (Application.platform != RuntimePlatform.WindowsEditor &&
                Application.platform != RuntimePlatform.WindowsPlayer
                )
            {
                return(false);
            }
#if STEAM_VR_SDK
            //
            bool ret = base.InitAllControllers();
            if (ret)
            {
                if (!OpenVRInterop.IsRuntimeInstalled() ||
                    !OpenVRInterop.IsHmdPresent())
                {
                    ret = false;
                }
                if (ret)
                {
                    if (inputTransforms.Length == 0)
                    {
                        inputTransforms = new InputTransform[1] {
                            null
                        };
                    }
                    controllers = new SteamVRController[maxControllers];
                    for (int i = 0; i < maxControllers; ++i)
                    {
                        controllers[i] = new SteamVRController(
                            string.Format(controllerFormat, i), i,
                            inputTransforms.Length == 1?inputTransforms[0]:inputTransforms[i]
                            );
                    }
                }
            }
            return(ret);
#else
            Log.d("SteamVRControllerManager", "Not Support!!!If you want to enable this feature,please follow these steps:\n" +
                  "    1) You need HTC Vive or other devices which can be developed by OpenVR,and remember SteamVR only works in pc.\n" +
                  "    2) Import \"SteamVR Plugin.unitypackage\"(you can download it from \"https://www.assetstore.unity3d.com/en/#!/content/32647\").\n" +
                  "    3) Add \"STEAM_VR_SDK\" to [Scripting Define Symbols] in [Player Settings](menu:Edit>Project Settings>Player).\n");
            return(false);
#endif
        }