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 }
static void Main(string[] args) { Console.WriteLine("Hello World!"); EVRInitError error = EVRInitError.None; var sys = OpenVR.Init(ref error); // var i = OpenVRInterop.InitInternal(ref error, EVRApplicationType.VRApplication_Utility); try { Console.WriteLine($"Error: {error}"); Console.WriteLine($"PResent: {sys.IsTrackedDeviceConnected(0)}"); Console.WriteLine($"PResent: {OpenVRInterop.IsHmdPresent()}"); } finally { OpenVR.Shutdown(); // OpenVRInterop.ShutdownInternal(); } }
/// <inheritdoc /> protected override CheckResult OnCheck() { var isApiReady = false; var isHmdPresent = false; try { isHmdPresent = OpenVRInterop.IsHmdPresent(); isApiReady = true; } catch (Exception e) { Logger.GetInstance(typeof(DefaultOpenVRManager)).Error(e.ToString()); } return(new CheckResult { IsApiReady = isApiReady, IsHmdPresent = isHmdPresent, IsRuntimeInstalled = Runtime.IsSteamVRInstalled(), IsRuntimeRunning = Runtime.IsSteamVRRunning() }); }