コード例 #1
0
ファイル: OpenVRContext.cs プロジェクト: yvanoff/veldrid
 internal static bool IsSupported()
 {
     try
     {
         return(OVR.IsHmdPresent());
     }
     catch
     {
         return(false);
     }
 }
コード例 #2
0
 private static SteamVR CreateInstance()
 {
     SteamVR.initializedState = SteamVR.InitializedStates.Initializing;
     try
     {
         EVRInitError evrinitError = EVRInitError.None;
         OpenVR.GetGenericInterface("IVRCompositor_022", ref evrinitError);
         OpenVR.Init(ref evrinitError, EVRApplicationType.VRApplication_Scene, "");
         CVRSystem           system              = OpenVR.System;
         string              manifestFile        = SteamVR.GetManifestFile();
         EVRApplicationError evrapplicationError = OpenVR.Applications.AddApplicationManifest(manifestFile, true);
         if (evrapplicationError != EVRApplicationError.None)
         {
             UnityEngine.Debug.LogError("<b>[SteamVR_Standalone]</b> Error adding vr manifest file: " + evrapplicationError.ToString());
         }
         int id = Process.GetCurrentProcess().Id;
         OpenVR.Applications.IdentifyApplication((uint)id, SteamVR_Settings.instance.editorAppKey);
         UnityEngine.Debug.Log("Is HMD here? " + OpenVR.IsHmdPresent().ToString());
         if (evrinitError != EVRInitError.None)
         {
             SteamVR.initializedState = SteamVR.InitializedStates.InitializeFailure;
             SteamVR.ReportError(evrinitError);
             SteamVR.ReportGeneralErrors();
             SteamVR_Events.Initializing.Send(false);
             return(null);
         }
         OpenVR.GetGenericInterface("IVROverlay_021", ref evrinitError);
         if (evrinitError != EVRInitError.None)
         {
             SteamVR.initializedState = SteamVR.InitializedStates.InitializeFailure;
             SteamVR.ReportError(evrinitError);
             SteamVR_Events.Initializing.Send(false);
             return(null);
         }
         OpenVR.GetGenericInterface("IVRInput_007", ref evrinitError);
         if (evrinitError != EVRInitError.None)
         {
             SteamVR.initializedState = SteamVR.InitializedStates.InitializeFailure;
             SteamVR.ReportError(evrinitError);
             SteamVR_Events.Initializing.Send(false);
             return(null);
         }
         SteamVR.settings = SteamVR_Settings.instance;
         if (Application.isEditor)
         {
             SteamVR.IdentifyEditorApplication(true);
         }
         SteamVR_Input.IdentifyActionsFile(true);
         if (SteamVR_Settings.instance.inputUpdateMode != SteamVR_UpdateModes.Nothing || SteamVR_Settings.instance.poseUpdateMode != SteamVR_UpdateModes.Nothing)
         {
             SteamVR_Input.Initialize(false);
         }
     }
     catch (Exception arg)
     {
         UnityEngine.Debug.LogError("<b>[SteamVR_Standalone]</b> " + arg);
         SteamVR_Events.Initializing.Send(false);
         return(null);
     }
     SteamVR._enabled         = true;
     SteamVR.initializedState = SteamVR.InitializedStates.InitializeSuccess;
     SteamVR_Events.Initializing.Send(true);
     return(new SteamVR());
 }