An infrared camera that tracks the position of a head-mounted display.
Ejemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        string[] ports = SerialPort.GetPortNames();

        Debug.Log("The following serial ports were found:");
        Debug.Log(SerialPort.GetPortNames().Count());

        mSerialPorts = new SerialPort[SerialPort.GetPortNames().Count()];

        int lPortId = 0;

        // Display each port name to the console.
        foreach (string port in ports)
        {
            Debug.Log(port);
            mSerialPorts [lPortId] = new SerialPort(port, 9600);
        }
        Byte[] mByteArray = new byte[2] {
            90, 90
        };
        foreach (SerialPort lPort in mSerialPorts)
        {
            lPort.Open();
            lPort.Write(mByteArray, 0, 2);
        }
        mTracker = new OVRTracker();
    }
Ejemplo n.º 2
0
	void Initialize()
	{
		if (display == null)
			display = new OVRDisplay():
		if (tracker == null)
			tracker = new OVRTracker():
		if (boundary == null)
			boundary = new OVRBoundary():

		reorientHMDOnControllerRecenter = _reorientHMDOnControllerRecenter:
	}
Ejemplo n.º 3
0
 void Initialize()
 {
     if (display == null)
     {
         display = new OVRDisplay();
     }
     if (tracker == null)
     {
         tracker = new OVRTracker();
     }
     if (boundary == null)
     {
         boundary = new OVRBoundary();
     }
 }
Ejemplo n.º 4
0
    void Initialize()
    {
        if (display == null)
        {
            display = new OVRDisplay();
        }
        if (tracker == null)
        {
            tracker = new OVRTracker();
        }
        if (boundary == null)
        {
            boundary = new OVRBoundary();
        }

        reorientHMDOnControllerRecenter = _reorientHMDOnControllerRecenter;
    }
        /// <summary>
        /// ローカルプレイヤーの生成位置調整
        /// </summary>
        private async UniTask SetLocalPlayerPositionAsync(CancellationToken ct)
        {
            //==========================
            // プレーヤーの生成位置となるオブジェクトを円状に作成
            //==========================

            var playerPositionObjectList = new List <GameObject>();

            //部屋の上限分の座標リストを作成
            for (var i = 0; i < ConstantData.PlayerUpperLimit; i++)
            {
                playerPositionObjectList.Add(new GameObject($"PlayerPos{i}"));
            }

            //オブジェクト間の角度差
            var angleDiff = 360f / playerPositionObjectList.Count;

            for (var i = 0; i < playerPositionObjectList.Count; i++)
            {
                var tmpPosition = playerPositionObjectList[i].transform.position;

                var angle = (90 - angleDiff * i) * Mathf.Deg2Rad;
                tmpPosition.x += ConstantData.Radius * Mathf.Cos(angle);
                tmpPosition.z += ConstantData.Radius * Mathf.Sin(angle);

                playerPositionObjectList[i].transform.position = tmpPosition;

                //中央を向かせる
                playerPositionObjectList[i].transform.LookAt(Vector3.zero);
            }

            //HMDがトラッキングされるまで待つ
            var ovrTracker = new OVRTracker();
            await UniTask.WaitUntil(() => ovrTracker.isEnabled, cancellationToken : ct);

            //CameraRigの座標、回転座標を調整
            var cameraRigTransform = GameObject.FindGameObjectWithTag("Player").transform;
            var targetTransform    = playerPositionObjectList[PhotonNetwork.LocalPlayer.GetPlayerNum()].transform;

            PlayerPositionUtility.CopyTargetTransform(cameraRigTransform, targetTransform);
            //アバターに適用
            transform.rotation = cameraRigTransform.rotation;
            transform.position = cameraRigTransform.position;
        }
Ejemplo n.º 6
0
	private void Awake()
	{
		// Only allow one instance at runtime.
		if (instance != null)
		{
			enabled = false;
			DestroyImmediate(this);
			return;
		}

		instance = this;

		Debug.Log("Unity v" + Application.unityVersion + ", " +
		          "Oculus Utilities v" + OVRPlugin.wrapperVersion + ", " +
		          "OVRPlugin v" + OVRPlugin.version + ", " +
		          "SDK v" + OVRPlugin.nativeSDKVersion + ".");

#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
		if (SystemInfo.graphicsDeviceType != UnityEngine.Rendering.GraphicsDeviceType.Direct3D11)
			Debug.LogWarning("VR rendering requires Direct3D11. Your graphics device: " + SystemInfo.graphicsDeviceType);
#endif

        // Detect whether this platform is a supported platform
        RuntimePlatform currPlatform = Application.platform;
        isSupportedPlatform |= currPlatform == RuntimePlatform.Android;
        //isSupportedPlatform |= currPlatform == RuntimePlatform.LinuxPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsPlayer;
        if (!isSupportedPlatform)
        {
            Debug.LogWarning("This platform is unsupported");
            return;
        }

#if UNITY_ANDROID && !UNITY_EDITOR
		// We want to set up our touchpad messaging system
		OVRTouchpad.Create();

        // Turn off chromatic aberration by default to save texture bandwidth.
        chromatic = false;
#endif

		if (display == null)
			display = new OVRDisplay();
		if (tracker == null)
			tracker = new OVRTracker();

		if (resetTrackerOnLoad)
			display.RecenterPose();
		
		// Disable the occlusion mesh by default until open issues with the preview window are resolved.
		OVRPlugin.occlusionMesh = false;

		OVRPlugin.ignoreVrFocus = runInBackground;
	}
Ejemplo n.º 7
0
	private void Awake()
	{
		// Only allow one instance at runtime.
		if (instance != null)
		{
			enabled = false;
			DestroyImmediate(this);
			return;
		}

		instance = this;

		System.Version netVersion = OVRPlugin.wrapperVersion;
		System.Version ovrVersion = OVRPlugin.version;
		
		Debug.Log("Unity v" + Application.unityVersion + ", " +
		          "Oculus Integration v" + netVersion + ", " +
		          "OVRPlugin v" + ovrVersion + ".");

        // Detect whether this platform is a supported platform
        RuntimePlatform currPlatform = Application.platform;
        isSupportedPlatform |= currPlatform == RuntimePlatform.Android;
        isSupportedPlatform |= currPlatform == RuntimePlatform.LinuxPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsPlayer;
        if (!isSupportedPlatform)
        {
            Debug.LogWarning("This platform is unsupported");
            return;
        }

#if !UNITY_ANDROID || UNITY_EDITOR
        if (OVRUnityVersionChecker.hasBuiltInVR)
        {
            Debug.LogWarning("The Oculus Unity Legacy Integration is only supported in Unity 4.x releases. For Unity 5.x, please migrate to the Oculus Utilities for Unity package and use Unity's built-in VR support (available in Unity 5.1 and later).");
            isVRPresent = false;
        }
		else if (!ovrIsInitialized)
		{
			//HACK: For some reason, Unity doesn't call UnitySetGraphicsDevice until we make the first P/Invoke call.
			OVRPluginEvent.eventBase = OVRPluginEvent.eventBase;

#if !UNITY_ANDROID || UNITY_EDITOR
			//Handle all log messages
			OVR_FlushLog(OnLogMessage);
#endif

			// If unable to load the Oculus Runtime.
			if (!OVRPlugin.initialized)
			{
				bool isBadWinRenderer =
					((Application.platform == RuntimePlatform.WindowsEditor ||
					  Application.platform == RuntimePlatform.WindowsPlayer) &&
					 !SystemInfo.graphicsDeviceVersion.Contains("Direct3D 11"));

				if (isBadWinRenderer)
					Debug.LogWarning("Only D3D11 is supported on Windows.");
				else
					Debug.LogWarning("Runtime is not present or no Rift attached. Running without VR.");

				// Runtime is not installed if ovr_Initialize() fails.
				isVRPresent = false;
				// Go monoscopic in response.
				monoscopic = true;
			}
			else
			{
				OVRPluginEvent.Issue(RenderEventType.InitRenderThread);

				isVRPresent = true;

#if UNITY_EDITOR
				if (!OVRUnityVersionChecker.hasEditorVRSupport)
				{
					// Only allow VR in standalones.
					isVRPresent = false;
					Debug.LogWarning("VR rendering is not supported in the editor. Please update to 4.6.7p4 or build a stand-alone player.");
				}
#endif
				if (netVersion.Major > ovrVersion.Major || netVersion.Major == ovrVersion.Major && netVersion.Minor > ovrVersion.Minor)
				{
					isVRPresent = false;
					Debug.LogWarning("Version check failed. Please make sure you are using OVRPlugin " +
					                 Ovr.Hmd.OVR_VERSION_STRING + " or newer.");
				}

				OVRPlugin.queueAheadFraction = 0f;

				ovrIsInitialized = true;
			}
		}

		SetEditorPlay(Application.isEditor);

#else // UNITY_ANDROID && !UNITY_EDITOR: Start of Android init.

		// Android integration does not dynamically load its runtime.
		isVRPresent = true;

		// log the unity version
		Debug.Log( "Unity Version: " + Application.unityVersion );

		// don't allow the application to run if orientation is not landscape left.
		if (Screen.orientation != ScreenOrientation.LandscapeLeft)
		{
			Debug.LogError("********************************************************************************\n");
			Debug.LogError("***** Default screen orientation must be set to landscape left for VR.\n" +
			               "***** Stopping application.\n");
			Debug.LogError("********************************************************************************\n");

			Debug.Break();
			Application.Quit();
		}

		// don't enable gyro, it is not used and triggers expensive display calls
		if (Input.gyro.enabled)
		{
			Debug.LogError("*** Auto-disabling Gyroscope ***");
			Input.gyro.enabled = false;
		}
		
		// NOTE: On Adreno Lollipop, it is an error to have antiAliasing set on the
		// main window surface with front buffer rendering enabled. The view will
		// render black.
		// On Adreno KitKat, some tiling control modes will cause the view to render
		// black.
		if (QualitySettings.antiAliasing > 1)
		{
			Debug.LogError("*** Antialiasing must be disabled for Gear VR ***");
		}

		// we sync in the TimeWarp, so we don't want unity
		// syncing elsewhere
		QualitySettings.vSyncCount = 0;

		// try to render at 60fps
		Application.targetFrameRate = 60;
		// don't allow the app to run in the background
		Application.runInBackground = false;
		// Disable screen dimming
		Screen.sleepTimeout = SleepTimeout.NeverSleep;

		if (!androidJavaInit)
		{
			AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
			activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
			// Prepare for the RenderThreadInit()
			SetInitVariables(activity.GetRawObject(), System.IntPtr.Zero);

#if USE_ENTITLEMENT_CHECK
			AndroidJavaObject entitlementChecker = new AndroidJavaObject("com.oculus.svclib.OVREntitlementChecker");
			entitlementChecker.CallStatic("doAutomatedCheck", activity);
#else
			Debug.Log( "Inhibiting Entitlement Check!" );
#endif

			androidJavaInit = true;
		}

		// We want to set up our touchpad messaging system
		OVRTouchpad.Create();

		InitVolumeController();

		// set an event delegate like this if you wish to handle events like "reorient".
		//SetVrApiEventDelegate( VrApiEventDefaultDelegate );
#endif // End of android init.

		prevEyeTextureAntiAliasing = OVRManager.instance.eyeTextureAntiAliasing;
		prevEyeTextureDepth = OVRManager.instance.eyeTextureDepth;
		prevEyeTextureFormat = OVRManager.instance.eyeTextureFormat;
        prevNativeTextureScale = OVRManager.instance.nativeTextureScale;
        prevVirtualTextureScale = OVRManager.instance.virtualTextureScale;
        prevMonoscopic = OVRManager.instance.monoscopic;
        prevHdr = OVRManager.instance.hdr;

		if (tracker == null)
			tracker = new OVRTracker();

		if (display == null)
			display = new OVRDisplay();
		else
			wasRecreated = true;

		if (input == null)
			input = new OVRInput();

		if (resetTrackerOnLoad)
			display.RecenterPose();

#if !UNITY_ANDROID || UNITY_EDITOR
		// Except for D3D9, SDK rendering forces vsync unless you pass ovrHmdCap_NoVSync to Hmd.SetEnabledCaps().
		if (timeWarp)
		{
			bool useUnityVSync = SystemInfo.graphicsDeviceVersion.Contains("Direct3D 9");
			QualitySettings.vSyncCount = useUnityVSync ? 1 : 0;
			QualitySettings.maxQueuedFrames = 0;
		}
#endif

#if UNITY_STANDALONE_WIN
		if (!OVRUnityVersionChecker.hasD3D9ExclusiveModeSupport && !display.isDirectMode && SystemInfo.graphicsDeviceVersion.Contains("Direct3D 9"))
		{
			MessageBox(0, "Direct3D 9 extended mode is not supported in this configuration. "
				+ "Please use direct display mode, a different graphics API, or rebuild the application with a newer Unity version."
				, "VR Configuration Warning", 0);
		}

		if (!OVRUnityVersionChecker.hasD3D11ExclusiveModeSupport && !display.isDirectMode && SystemInfo.graphicsDeviceVersion.Contains("Direct3D 11"))
		{
			MessageBox(0, "Direct3D 11 extended mode is not supported in this configuration. "
				+ "Please use direct display mode, a different graphics API, or rebuild the application with a newer Unity version."
				, "VR Configuration Warning", 0);
		}
#endif
	}
Ejemplo n.º 8
0
    private void Awake()
    {
        // Only allow one instance at runtime.
        if (instance != null)
        {
            enabled = false;
            DestroyImmediate(this);
            return;
        }

        instance = this;

        var netVersion = new System.Version(OVRPlugin.WrapperVersion);

        System.Version ovrVersion    = new System.Version("0.0.0");
        var            versionString = OVRPlugin.version;
        var            success       = false;

        try {
            ovrVersion = new System.Version(versionString);
            success    = true;
        } catch (Exception e) {
            Debug.Log("Failed to parse Oculus version string \"" + versionString + "\" with message \"" + e.Message + "\".");
        }
        if (!success || netVersion > ovrVersion)
        {
            Debug.LogWarning("Version check failed. Please make sure you are using Oculus runtime " +
                             OVRPlugin.WrapperVersion + " or newer.");
        }

        Debug.Log("Unity v" + Application.unityVersion + ", " +
                  "Oculus Utilities v" + netVersion + ", " +
                  "OVRPlugin v" + ovrVersion + ".");

#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
        if (SystemInfo.graphicsDeviceType != UnityEngine.Rendering.GraphicsDeviceType.Direct3D11)
        {
            Debug.LogWarning("VR rendering requires Direct3D11. Your graphics device: " + SystemInfo.graphicsDeviceType);
        }
#endif

        // Detect whether this platform is a supported platform
        RuntimePlatform currPlatform = Application.platform;
        isSupportedPlatform |= currPlatform == RuntimePlatform.Android;
        //isSupportedPlatform |= currPlatform == RuntimePlatform.LinuxPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsPlayer;
        if (!isSupportedPlatform)
        {
            Debug.LogWarning("This platform is unsupported");
            return;
        }

#if UNITY_ANDROID && !UNITY_EDITOR
        // We want to set up our touchpad messaging system
        OVRTouchpad.Create();

        // Turn off chromatic aberration by default to save texture bandwidth.
        chromatic = false;
#endif

        InitVolumeController();

        if (display == null)
        {
            display = new OVRDisplay();
        }
        if (tracker == null)
        {
            tracker = new OVRTracker();
        }

        if (resetTrackerOnLoad)
        {
            display.RecenterPose();
        }
    }
Ejemplo n.º 9
0
    private void Awake()
    {
        // Only allow one instance at runtime.
        if (instance != null)
        {
            enabled = false;
            DestroyImmediate(this);
            return;
        }

        instance = this;

        Debug.Log("Unity v" + Application.unityVersion + ", " +
                  "Oculus Utilities v" + OVRPlugin.wrapperVersion + ", " +
                  "OVRPlugin v" + OVRPlugin.version + ", " +
                  "SDK v" + OVRPlugin.nativeSDKVersion + ".");

#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
        if (SystemInfo.graphicsDeviceType != UnityEngine.Rendering.GraphicsDeviceType.Direct3D11)
        {
            Debug.LogWarning("VR rendering requires Direct3D11. Your graphics device: " + SystemInfo.graphicsDeviceType);
        }
#endif

        // Detect whether this platform is a supported platform
        RuntimePlatform currPlatform = Application.platform;
        isSupportedPlatform |= currPlatform == RuntimePlatform.Android;
        //isSupportedPlatform |= currPlatform == RuntimePlatform.LinuxPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsPlayer;
        if (!isSupportedPlatform)
        {
            Debug.LogWarning("This platform is unsupported");
            return;
        }

#if UNITY_ANDROID && !UNITY_EDITOR
        // We want to set up our touchpad messaging system
        OVRTouchpad.Create();

        // Turn off chromatic aberration by default to save texture bandwidth.
        chromatic = false;
#endif

        if (display == null)
        {
            display = new OVRDisplay();
        }
        if (tracker == null)
        {
            tracker = new OVRTracker();
        }
        if (boundary == null)
        {
            boundary = new OVRBoundary();
        }

        if (resetTrackerOnLoad)
        {
            display.RecenterPose();
        }

        // Disable the occlusion mesh by default until open issues with the preview window are resolved.
        OVRPlugin.occlusionMesh = false;

        OVRPlugin.ignoreVrFocus = runInBackground;
    }
Ejemplo n.º 10
0
	private void Awake()
	{
		// Only allow one instance at runtime.
		if (instance != null)
		{
			enabled = false;
			DestroyImmediate(this);
			return;
		}

		instance = this;

#if !UNITY_ANDROID || UNITY_EDITOR
		if (!ovrIsInitialized)
		{
			OVR_Initialize();
			OVRPluginEvent.Issue(RenderEventType.Initialize);

			ovrIsInitialized = true;
		}

		var netVersion = new System.Version(Ovr.Hmd.OVR_VERSION_STRING);
		System.Version ovrVersion = new System.Version("0.0.0");
		var versionString = Ovr.Hmd.GetVersionString();
		var success = false;
		try {
			ovrVersion = new System.Version(versionString);
			success = true;
		} catch (Exception e) {
			Debug.Log("Failed to parse Oculus version string \"" + versionString + "\" with message \"" + e.Message + "\".");
		}
		if (!success || netVersion > ovrVersion)
			Debug.LogWarning("Version check failed. Please make sure you are using Oculus runtime " +
			                 Ovr.Hmd.OVR_VERSION_STRING + " or newer.");
#endif

        // Detect whether this platform is a supported platform
        RuntimePlatform currPlatform = Application.platform;
        isSupportedPlatform |= currPlatform == RuntimePlatform.Android;
        isSupportedPlatform |= currPlatform == RuntimePlatform.LinuxPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsPlayer;
        if (!isSupportedPlatform)
        {
            Debug.LogWarning("This platform is unsupported");
            return;
        }

#if UNITY_ANDROID && !UNITY_EDITOR

		// log the unity version
		Debug.Log( "Unity Version: " + Application.unityVersion );

		// don't allow the application to run if orientation is not landscape left.
		if (Screen.orientation != ScreenOrientation.LandscapeLeft)
		{
			Debug.LogError("********************************************************************************\n");
			Debug.LogError("***** Default screen orientation must be set to landscape left for VR.\n" +
			               "***** Stopping application.\n");
			Debug.LogError("********************************************************************************\n");

			Debug.Break();
			Application.Quit();
		}

		// don't enable gyro, it is not used and triggers expensive display calls
		if (Input.gyro.enabled)
		{
			Debug.LogError("*** Auto-disabling Gyroscope ***");
			Input.gyro.enabled = false;
		}
		
		// NOTE: On Adreno Lollipop, it is an error to have antiAliasing set on the
		// main window surface with front buffer rendering enabled. The view will
		// render black.
		// On Adreno KitKat, some tiling control modes will cause the view to render
		// black.
		if (QualitySettings.antiAliasing > 1)
		{
			Debug.LogError("*** Antialiasing must be disabled for Gear VR ***");
		}

		// we sync in the TimeWarp, so we don't want unity
		// syncing elsewhere
		QualitySettings.vSyncCount = 0;

		// try to render at 60fps
		Application.targetFrameRate = 60;
		// don't allow the app to run in the background
		Application.runInBackground = false;
		// Disable screen dimming
		Screen.sleepTimeout = SleepTimeout.NeverSleep;

		if (!androidJavaInit)
		{
			AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
			activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
			javaVrActivityClass = new AndroidJavaClass("com.oculusvr.vrlib.VrActivity");
			// Prepare for the RenderThreadInit()
			SetInitVariables(activity.GetRawObject(), javaVrActivityClass.GetRawClass());

#if USE_ENTITLEMENT_CHECK
			AndroidJavaObject entitlementChecker = new AndroidJavaObject("com.oculus.svclib.OVREntitlementChecker");
			entitlementChecker.CallStatic("doAutomatedCheck", activity);
#else
			Debug.Log( "Inhibiting Entitlement Check!" );
#endif

			androidJavaInit = true;
		}

		// We want to set up our touchpad messaging system
		OVRTouchpad.Create();

		InitVolumeController();
#else
		SetEditorPlay(Application.isEditor);
#endif

		prevEyeTextureAntiAliasing = OVRManager.instance.eyeTextureAntiAliasing;
		prevEyeTextureDepth = OVRManager.instance.eyeTextureDepth;
		prevEyeTextureFormat = OVRManager.instance.eyeTextureFormat;
        prevNativeTextureScale = OVRManager.instance.nativeTextureScale;
        prevVirtualTextureScale = OVRManager.instance.virtualTextureScale;
        prevMonoscopic = OVRManager.instance.monoscopic;
        prevHdr = OVRManager.instance.hdr;

		if (display == null)
			display = new OVRDisplay();
		if (tracker == null)
			tracker = new OVRTracker();

		if (resetTrackerOnLoad)
			display.RecenterPose();

#if !UNITY_ANDROID || UNITY_EDITOR
		// Except for D3D9, SDK rendering forces vsync unless you pass ovrHmdCap_NoVSync to Hmd.SetEnabledCaps().
		if (timeWarp)
		{
			bool useUnityVSync = SystemInfo.graphicsDeviceVersion.Contains("Direct3D 9");
			QualitySettings.vSyncCount = useUnityVSync ? 1 : 0;
		}
#endif

#if UNITY_STANDALONE_WIN
		if (!OVRUnityVersionChecker.hasD3D9ExclusiveModeSupport && !display.isDirectMode && SystemInfo.graphicsDeviceVersion.Contains("Direct3D 9"))
		{
			MessageBox(0, "Direct3D 9 extended mode is not supported in this configuration. "
				+ "Please use direct display mode, a different graphics API, or rebuild the application with a newer Unity version."
				, "VR Configuration Warning", 0);
		}

		if (!OVRUnityVersionChecker.hasD3D11ExclusiveModeSupport && !display.isDirectMode && SystemInfo.graphicsDeviceVersion.Contains("Direct3D 11"))
		{
			MessageBox(0, "Direct3D 11 extended mode is not supported in this configuration. "
				+ "Please use direct display mode, a different graphics API, or rebuild the application with a newer Unity version."
				, "VR Configuration Warning", 0);
		}
#endif
	}
Ejemplo n.º 11
0
    private void Awake()
    {
        // Only allow one instance at runtime.
        if (instance != null)
        {
            enabled = false;
            DestroyImmediate(this);
            return;
        }

        instance = this;

        System.Version netVersion = OVRPlugin.wrapperVersion;
        System.Version ovrVersion = OVRPlugin.version;

        Debug.Log("Unity v" + Application.unityVersion + ", " +
                  "Oculus Integration v" + netVersion + ", " +
                  "OVRPlugin v" + ovrVersion + ".");

        // Detect whether this platform is a supported platform
        RuntimePlatform currPlatform = Application.platform;

        isSupportedPlatform |= currPlatform == RuntimePlatform.Android;
        isSupportedPlatform |= currPlatform == RuntimePlatform.LinuxPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsPlayer;
        if (!isSupportedPlatform)
        {
            Debug.LogWarning("This platform is unsupported");
            return;
        }

#if !UNITY_ANDROID || UNITY_EDITOR
        if (OVRUnityVersionChecker.hasBuiltInVR)
        {
            Debug.LogWarning("The Oculus Unity Legacy Integration is only supported in Unity 4.x releases. For Unity 5.x, please migrate to the Oculus Utilities for Unity package and use Unity's built-in VR support (available in Unity 5.1 and later).");
            isVRPresent = false;
        }
        else if (!ovrIsInitialized)
        {
            //HACK: For some reason, Unity doesn't call UnitySetGraphicsDevice until we make the first P/Invoke call.
            OVRPluginEvent.eventBase = OVRPluginEvent.eventBase;

#if !UNITY_ANDROID || UNITY_EDITOR
            //Handle all log messages
            OVR_FlushLog(OnLogMessage);
#endif

            // If unable to load the Oculus Runtime.
            if (!OVRPlugin.initialized)
            {
                bool isBadWinRenderer =
                    ((Application.platform == RuntimePlatform.WindowsEditor ||
                      Application.platform == RuntimePlatform.WindowsPlayer) &&
                     !SystemInfo.graphicsDeviceVersion.Contains("Direct3D 11"));

                if (isBadWinRenderer)
                {
                    Debug.LogWarning("Only D3D11 is supported on Windows.");
                }
                else
                {
                    Debug.LogWarning("Runtime is not present or no Rift attached. Running without VR.");
                }

                // Runtime is not installed if ovr_Initialize() fails.
                isVRPresent = false;
                // Go monoscopic in response.
                monoscopic = true;
            }
            else
            {
                OVRPluginEvent.Issue(RenderEventType.InitRenderThread);

                isVRPresent = true;

#if UNITY_EDITOR
                if (!OVRUnityVersionChecker.hasEditorVRSupport)
                {
                    // Only allow VR in standalones.
                    isVRPresent = false;
                    Debug.LogWarning("VR rendering is not supported in the editor. Please update to 4.6.7p4 or build a stand-alone player.");
                }
#endif
                if (netVersion.Major > ovrVersion.Major || netVersion.Major == ovrVersion.Major && netVersion.Minor > ovrVersion.Minor)
                {
                    isVRPresent = false;
                    Debug.LogWarning("Version check failed. Please make sure you are using OVRPlugin " +
                                     Ovr.Hmd.OVR_VERSION_STRING + " or newer.");
                }

                OVRPlugin.queueAheadFraction = 0f;

                ovrIsInitialized = true;
            }
        }

        SetEditorPlay(Application.isEditor);
#else // UNITY_ANDROID && !UNITY_EDITOR: Start of Android init.
        // Android integration does not dynamically load its runtime.
        isVRPresent = true;

        // log the unity version
        Debug.Log("Unity Version: " + Application.unityVersion);

        // don't allow the application to run if orientation is not landscape left.
        if (Screen.orientation != ScreenOrientation.LandscapeLeft)
        {
            Debug.LogError("********************************************************************************\n");
            Debug.LogError("***** Default screen orientation must be set to landscape left for VR.\n" +
                           "***** Stopping application.\n");
            Debug.LogError("********************************************************************************\n");

            Debug.Break();
            Application.Quit();
        }

        // don't enable gyro, it is not used and triggers expensive display calls
        if (Input.gyro.enabled)
        {
            Debug.LogError("*** Auto-disabling Gyroscope ***");
            Input.gyro.enabled = false;
        }

        // NOTE: On Adreno Lollipop, it is an error to have antiAliasing set on the
        // main window surface with front buffer rendering enabled. The view will
        // render black.
        // On Adreno KitKat, some tiling control modes will cause the view to render
        // black.
        if (QualitySettings.antiAliasing > 1)
        {
            Debug.LogError("*** Antialiasing must be disabled for Gear VR ***");
        }

        // we sync in the TimeWarp, so we don't want unity
        // syncing elsewhere
        QualitySettings.vSyncCount = 0;

        // try to render at 60fps
        Application.targetFrameRate = 60;
        // don't allow the app to run in the background
        Application.runInBackground = false;
        // Disable screen dimming
        Screen.sleepTimeout = SleepTimeout.NeverSleep;

        if (!androidJavaInit)
        {
            AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            activity = unityPlayer.GetStatic <AndroidJavaObject>("currentActivity");
            // Prepare for the RenderThreadInit()
            SetInitVariables(activity.GetRawObject(), System.IntPtr.Zero);

#if USE_ENTITLEMENT_CHECK
            AndroidJavaObject entitlementChecker = new AndroidJavaObject("com.oculus.svclib.OVREntitlementChecker");
            entitlementChecker.CallStatic("doAutomatedCheck", activity);
#else
            Debug.Log("Inhibiting Entitlement Check!");
#endif

            androidJavaInit = true;
        }

        // We want to set up our touchpad messaging system
        OVRTouchpad.Create();

        InitVolumeController();

        // set an event delegate like this if you wish to handle events like "reorient".
        //SetVrApiEventDelegate( VrApiEventDefaultDelegate );
#endif // End of android init.

        prevEyeTextureAntiAliasing = OVRManager.instance.eyeTextureAntiAliasing;
        prevEyeTextureDepth        = OVRManager.instance.eyeTextureDepth;
        prevEyeTextureFormat       = OVRManager.instance.eyeTextureFormat;
        prevNativeTextureScale     = OVRManager.instance.nativeTextureScale;
        prevVirtualTextureScale    = OVRManager.instance.virtualTextureScale;
        prevMonoscopic             = OVRManager.instance.monoscopic;
        prevHdr = OVRManager.instance.hdr;

        if (tracker == null)
        {
            tracker = new OVRTracker();
        }

        if (display == null)
        {
            display = new OVRDisplay();
        }
        else
        {
            wasRecreated = true;
        }

        if (input == null)
        {
            input = new OVRInput();
        }

        if (resetTrackerOnLoad)
        {
            display.RecenterPose();
        }

#if !UNITY_ANDROID || UNITY_EDITOR
        // Except for D3D9, SDK rendering forces vsync unless you pass ovrHmdCap_NoVSync to Hmd.SetEnabledCaps().
        if (timeWarp)
        {
            bool useUnityVSync = SystemInfo.graphicsDeviceVersion.Contains("Direct3D 9");
            QualitySettings.vSyncCount      = useUnityVSync ? 1 : 0;
            QualitySettings.maxQueuedFrames = 0;
        }
#endif

#if UNITY_STANDALONE_WIN
        if (!OVRUnityVersionChecker.hasD3D9ExclusiveModeSupport && !display.isDirectMode && SystemInfo.graphicsDeviceVersion.Contains("Direct3D 9"))
        {
            MessageBox(0, "Direct3D 9 extended mode is not supported in this configuration. "
                       + "Please use direct display mode, a different graphics API, or rebuild the application with a newer Unity version."
                       , "VR Configuration Warning", 0);
        }

        if (!OVRUnityVersionChecker.hasD3D11ExclusiveModeSupport && !display.isDirectMode && SystemInfo.graphicsDeviceVersion.Contains("Direct3D 11"))
        {
            MessageBox(0, "Direct3D 11 extended mode is not supported in this configuration. "
                       + "Please use direct display mode, a different graphics API, or rebuild the application with a newer Unity version."
                       , "VR Configuration Warning", 0);
        }
#endif
    }
Ejemplo n.º 12
0
    private void Awake()
    {
        // Only allow one instance at runtime.
        if (instance != null)
        {
            enabled = false;
            DestroyImmediate(this);
            return;
        }

        instance = this;

#if !UNITY_ANDROID || UNITY_EDITOR
        if (!ovrIsInitialized)
        {
            OVR_Initialize();
            OVRPluginEvent.Issue(RenderEventType.Initialize);

            ovrIsInitialized = true;
        }

        var            netVersion    = new System.Version(Ovr.Hmd.OVR_VERSION_STRING);
        System.Version ovrVersion    = new System.Version("0.0.0");
        var            versionString = Ovr.Hmd.GetVersionString();
        var            success       = false;
        try {
            ovrVersion = new System.Version(versionString);
            success    = true;
        } catch (Exception e) {
            Debug.Log("Failed to parse Oculus version string \"" + versionString + "\" with message \"" + e.Message + "\".");
        }
        if (!success || netVersion > ovrVersion)
        {
            Debug.LogWarning("Version check failed. Please make sure you are using Oculus runtime " +
                             Ovr.Hmd.OVR_VERSION_STRING + " or newer.");
        }
#endif

        // Detect whether this platform is a supported platform
        RuntimePlatform currPlatform = Application.platform;
        isSupportedPlatform |= currPlatform == RuntimePlatform.Android;
        isSupportedPlatform |= currPlatform == RuntimePlatform.LinuxPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsPlayer;
        if (!isSupportedPlatform)
        {
            Debug.LogWarning("This platform is unsupported");
            return;
        }

#if UNITY_ANDROID && !UNITY_EDITOR
        // log the unity version
        Debug.Log("Unity Version: " + Application.unityVersion);

        // don't allow the application to run if orientation is not landscape left.
        if (Screen.orientation != ScreenOrientation.LandscapeLeft)
        {
            Debug.LogError("********************************************************************************\n");
            Debug.LogError("***** Default screen orientation must be set to landscape left for VR.\n" +
                           "***** Stopping application.\n");
            Debug.LogError("********************************************************************************\n");

            Debug.Break();
            Application.Quit();
        }

        // don't enable gyro, it is not used and triggers expensive display calls
        if (Input.gyro.enabled)
        {
            Debug.LogError("*** Auto-disabling Gyroscope ***");
            Input.gyro.enabled = false;
        }

        // NOTE: On Adreno Lollipop, it is an error to have antiAliasing set on the
        // main window surface with front buffer rendering enabled. The view will
        // render black.
        // On Adreno KitKat, some tiling control modes will cause the view to render
        // black.
        if (QualitySettings.antiAliasing > 1)
        {
            Debug.LogError("*** Antialiasing must be disabled for Gear VR ***");
        }

        // we sync in the TimeWarp, so we don't want unity
        // syncing elsewhere
        QualitySettings.vSyncCount = 0;

        // try to render at 60fps
        Application.targetFrameRate = 60;
        // don't allow the app to run in the background
        Application.runInBackground = false;
        // Disable screen dimming
        Screen.sleepTimeout = SleepTimeout.NeverSleep;

        if (!androidJavaInit)
        {
            AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            activity            = unityPlayer.GetStatic <AndroidJavaObject>("currentActivity");
            javaVrActivityClass = new AndroidJavaClass("com.oculusvr.vrlib.VrActivity");
            // Prepare for the RenderThreadInit()
            SetInitVariables(activity.GetRawObject(), javaVrActivityClass.GetRawClass());

#if USE_ENTITLEMENT_CHECK
            AndroidJavaObject entitlementChecker = new AndroidJavaObject("com.oculus.svclib.OVREntitlementChecker");
            entitlementChecker.CallStatic("doAutomatedCheck", activity);
#else
            Debug.Log("Inhibiting Entitlement Check!");
#endif

            androidJavaInit = true;
        }

        // We want to set up our touchpad messaging system
        OVRTouchpad.Create();

        InitVolumeController();

        // set an event delegate like this if you wish to handle events like "reorient".
        //SetVrApiEventDelegate( VrApiEventDefaultDelegate );
#else
        SetEditorPlay(Application.isEditor);
#endif

        prevEyeTextureAntiAliasing = OVRManager.instance.eyeTextureAntiAliasing;
        prevEyeTextureDepth        = OVRManager.instance.eyeTextureDepth;
        prevEyeTextureFormat       = OVRManager.instance.eyeTextureFormat;
        prevNativeTextureScale     = OVRManager.instance.nativeTextureScale;
        prevVirtualTextureScale    = OVRManager.instance.virtualTextureScale;
        prevMonoscopic             = OVRManager.instance.monoscopic;
        prevHdr = OVRManager.instance.hdr;

        if (display == null)
        {
            display = new OVRDisplay();
        }
        if (tracker == null)
        {
            tracker = new OVRTracker();
        }

        if (resetTrackerOnLoad)
        {
            display.RecenterPose();
        }

#if !UNITY_ANDROID || UNITY_EDITOR
        // Except for D3D9, SDK rendering forces vsync unless you pass ovrHmdCap_NoVSync to Hmd.SetEnabledCaps().
        if (timeWarp)
        {
            bool useUnityVSync = SystemInfo.graphicsDeviceVersion.Contains("Direct3D 9");
            QualitySettings.vSyncCount = useUnityVSync ? 1 : 0;
        }
#endif

#if UNITY_STANDALONE_WIN
        if (!OVRUnityVersionChecker.hasD3D9ExclusiveModeSupport && !display.isDirectMode && SystemInfo.graphicsDeviceVersion.Contains("Direct3D 9"))
        {
            MessageBox(0, "Direct3D 9 extended mode is not supported in this configuration. "
                       + "Please use direct display mode, a different graphics API, or rebuild the application with a newer Unity version."
                       , "VR Configuration Warning", 0);
        }

        if (!OVRUnityVersionChecker.hasD3D11ExclusiveModeSupport && !display.isDirectMode && SystemInfo.graphicsDeviceVersion.Contains("Direct3D 11"))
        {
            MessageBox(0, "Direct3D 11 extended mode is not supported in this configuration. "
                       + "Please use direct display mode, a different graphics API, or rebuild the application with a newer Unity version."
                       , "VR Configuration Warning", 0);
        }
#endif
    }
	private void Awake()
	{
		// Only allow one instance at runtime.
		if (instance != null)
		{
			enabled = false;
			DestroyImmediate(this);
			return;
		}

		instance = this;

		System.Version netVersion = OVRPlugin.wrapperVersion;
		System.Version ovrVersion = OVRPlugin.version;

		Debug.Log("Unity v" + Application.unityVersion + ", " +
		          "Oculus Utilities v" + netVersion + ", " +
		          "OVRPlugin v" + ovrVersion + ".");

#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
		if (SystemInfo.graphicsDeviceType != UnityEngine.Rendering.GraphicsDeviceType.Direct3D11)
			Debug.LogWarning("VR rendering requires Direct3D11. Your graphics device: " + SystemInfo.graphicsDeviceType);
#endif

        // Detect whether this platform is a supported platform
        RuntimePlatform currPlatform = Application.platform;
        isSupportedPlatform |= currPlatform == RuntimePlatform.Android;
        //isSupportedPlatform |= currPlatform == RuntimePlatform.LinuxPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsPlayer;
        if (!isSupportedPlatform)
        {
            Debug.LogWarning("This platform is unsupported");
            return;
        }

#if UNITY_ANDROID && !UNITY_EDITOR
		// We want to set up our touchpad messaging system
		OVRTouchpad.Create();

        // Turn off chromatic aberration by default to save texture bandwidth.
        chromatic = false;
#endif

        InitVolumeController();

		if (display == null)
			display = new OVRDisplay();
		if (tracker == null)
			tracker = new OVRTracker();
		if (input == null)
			input = new OVRInput();

		if (resetTrackerOnLoad)
			display.RecenterPose();
	}
Ejemplo n.º 14
0
	private void Awake()
	{
		// Only allow one instance at runtime.
		if (instance != null)
		{
			enabled = false;
			DestroyImmediate(this);
			return;
		}

		instance = this;

#if !UNITY_ANDROID || UNITY_EDITOR
		var netVersion = new System.Version(Ovr.Hmd.OVR_VERSION_STRING);
		var ovrVersion = new System.Version(Ovr.Hmd.GetVersionString());
		if (netVersion > ovrVersion)
			Debug.LogWarning("Using an older version of LibOVR.");
#endif

        // Detect whether this platform is a supported platform
        RuntimePlatform currPlatform = Application.platform;
        isSupportedPlatform |= currPlatform == RuntimePlatform.Android;
        isSupportedPlatform |= currPlatform == RuntimePlatform.LinuxPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsPlayer;
        if (!isSupportedPlatform)
        {
            Debug.LogWarning("This platform is unsupported");
            return;
        }

#if UNITY_ANDROID && !UNITY_EDITOR
		Application.targetFrameRate = 60;
		// don't allow the app to run in the background
		Application.runInBackground = false;
		// Disable screen dimming
		Screen.sleepTimeout = SleepTimeout.NeverSleep;

		if (!androidJavaInit)
		{
			AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
			activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
			javaVrActivityClass = new AndroidJavaClass("com.oculusvr.vrlib.VrActivity");
			// Prepare for the RenderThreadInit()
			SetInitVariables(activity.GetRawObject(), javaVrActivityClass.GetRawClass());
			
			androidJavaInit = true;
		}

		// We want to set up our touchpad messaging system
		OVRTouchpad.Create();
		// This will trigger the init on the render thread
		InitRenderThread();
#else
		SetEditorPlay(Application.isEditor);
#endif

		display = new OVRDisplay();
		tracker = new OVRTracker();

		// Except for D3D9, SDK rendering forces vsync unless you pass ovrHmdCap_NoVSync to Hmd.SetEnabledCaps().
		if (timeWarp)
		{
			bool useUnityVSync = SystemInfo.graphicsDeviceVersion.Contains("Direct3D 9");
			QualitySettings.vSyncCount = useUnityVSync ? 1 : 0;
		}
	}
Ejemplo n.º 15
0
    private void Awake()
    {
        // Only allow one instance at runtime.
        if (instance != null)
        {
            enabled = false;
            DestroyImmediate(this);
            return;
        }

        instance = this;

                #if !UNITY_ANDROID || UNITY_EDITOR
        if (!ovrIsInitialized)
        {
            OVR_Initialize();
            OVRPluginEvent.Issue(RenderEventType.Initialize);

            ovrIsInitialized = true;
        }

        var netVersion = new System.Version(Ovr.Hmd.OVR_VERSION_STRING);
        var ovrVersion = new System.Version(Ovr.Hmd.GetVersionString());
        if (netVersion > ovrVersion)
        {
            Debug.LogWarning("Using an older version of LibOVR.");
        }
                #endif

        // Detect whether this platform is a supported platform
        RuntimePlatform currPlatform = Application.platform;
        isSupportedPlatform |= currPlatform == RuntimePlatform.Android;
        isSupportedPlatform |= currPlatform == RuntimePlatform.LinuxPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsPlayer;
        if (!isSupportedPlatform)
        {
            Debug.LogWarning("This platform is unsupported");
            return;
        }

                #if UNITY_ANDROID && !UNITY_EDITOR
        // don't allow the application to run if orientation is not landscape left.
        if (Screen.orientation != ScreenOrientation.LandscapeLeft)
        {
            Debug.LogError("********************************************************************************\n");
            Debug.LogError("***** Default screen orientation must be set to landscape left for VR.\n" +
                           "***** Stopping application.\n");
            Debug.LogError("********************************************************************************\n");

            Debug.Break();
            Application.Quit();
        }

        // don't enable gyro, it is not used and triggers expensive display calls
        if (Input.gyro.enabled)
        {
            Debug.LogError("*** Auto-disabling Gyroscope ***");
            Input.gyro.enabled = false;
        }

        // NOTE: On Adreno Lollipop, it is an error to have antiAliasing set on the
        // main window surface with front buffer rendering enabled. The view will
        // render black.
        // On Adreno KitKat, some tiling control modes will cause the view to render
        // black.
        if (QualitySettings.antiAliasing > 1)
        {
            Debug.LogError("*** Antialiasing must be disabled for Gear VR ***");
        }

        // we sync in the TimeWarp, so we don't want unity
        // syncing elsewhere
        QualitySettings.vSyncCount = 0;

        // try to render at 60fps
        Application.targetFrameRate = 60;
        // don't allow the app to run in the background
        Application.runInBackground = false;
        // Disable screen dimming
        Screen.sleepTimeout = SleepTimeout.NeverSleep;

        if (!androidJavaInit)
        {
            AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            activity            = unityPlayer.GetStatic <AndroidJavaObject>("currentActivity");
            javaVrActivityClass = new AndroidJavaClass("com.oculusvr.vrlib.VrActivity");
            // Prepare for the RenderThreadInit()
            SetInitVariables(activity.GetRawObject(), javaVrActivityClass.GetRawClass());

                        #if !INHIBIT_ENTITLEMENT_CHECK
            AndroidJavaObject entitlementChecker = new AndroidJavaObject("com.oculus.svclib.OVREntitlementChecker");
            entitlementChecker.CallStatic("doAutomatedCheck", activity);
                        #else
            Debug.Log("Inhibiting Entitlement Check!");
                        #endif

            androidJavaInit = true;
        }

        // We want to set up our touchpad messaging system
        OVRTouchpad.Create();

        InitVolumeController();
                #else
        SetEditorPlay(Application.isEditor);
                #endif

        prevEyeTextureAntiAliasing = OVRManager.instance.eyeTextureAntiAliasing;
        prevEyeTextureDepth        = OVRManager.instance.eyeTextureDepth;
        prevEyeTextureFormat       = OVRManager.instance.eyeTextureFormat;
        prevNativeTextureScale     = OVRManager.instance.nativeTextureScale;
        prevVirtualTextureScale    = OVRManager.instance.virtualTextureScale;
        prevMonoscopic             = OVRManager.instance.monoscopic;
        prevHdr = OVRManager.instance.hdr;

        if (display == null)
        {
            display = new OVRDisplay();
        }
        if (tracker == null)
        {
            tracker = new OVRTracker();
        }

        if (resetTrackerOnLoad)
        {
            display.RecenterPose();
        }

                #if !UNITY_ANDROID || UNITY_EDITOR
        // Except for D3D9, SDK rendering forces vsync unless you pass ovrHmdCap_NoVSync to Hmd.SetEnabledCaps().
        if (timeWarp)
        {
            bool useUnityVSync = SystemInfo.graphicsDeviceVersion.Contains("Direct3D 9");
            QualitySettings.vSyncCount = useUnityVSync ? 1 : 0;
        }
                #endif

                #if (UNITY_STANDALONE_WIN && (UNITY_4_6 || UNITY_4_5))
        bool unity_4_6   = false;
        bool unity_4_5_2 = false;
        bool unity_4_5_3 = false;
        bool unity_4_5_4 = false;
        bool unity_4_5_5 = false;

                #if (UNITY_4_6)
        unity_4_6 = true;
                #elif (UNITY_4_5_2)
        unity_4_5_2 = true;
                #elif (UNITY_4_5_3)
        unity_4_5_3 = true;
                #elif (UNITY_4_5_4)
        unity_4_5_4 = true;
                #elif (UNITY_4_5_5)
        unity_4_5_5 = true;
                #endif

        // Detect correct Unity releases which contain the fix for D3D11 exclusive mode.
        string version = Application.unityVersion;
        int    releaseNumber;
        bool   releaseNumberFound = Int32.TryParse(Regex.Match(version, @"\d+$").Value, out releaseNumber);

        // Exclusive mode was broken for D3D9 in Unity 4.5.2p2 - 4.5.4 and 4.6 builds prior to beta 21
        bool unsupportedExclusiveModeD3D9 = (unity_4_6 && version.Last(char.IsLetter) == 'b' && releaseNumberFound && releaseNumber < 21) ||
                                            (unity_4_5_2 && version.Last(char.IsLetter) == 'p' && releaseNumberFound && releaseNumber >= 2) ||
                                            (unity_4_5_3) ||
                                            (unity_4_5_4);

        // Exclusive mode was broken for D3D11 in Unity 4.5.2p2 - 4.5.5p2 and 4.6 builds prior to f1
        bool unsupportedExclusiveModeD3D11 = (unity_4_6 && version.Last(char.IsLetter) == 'b') ||
                                             (unity_4_5_2 && version.Last(char.IsLetter) == 'p' && releaseNumberFound && releaseNumber >= 2) ||
                                             (unity_4_5_3) ||
                                             (unity_4_5_4) ||
                                             (unity_4_5_5 && version.Last(char.IsLetter) == 'f') ||
                                             (unity_4_5_5 && version.Last(char.IsLetter) == 'p' && releaseNumberFound && releaseNumber < 3);

        if (unsupportedExclusiveModeD3D9 && !display.isDirectMode && SystemInfo.graphicsDeviceVersion.Contains("Direct3D 9"))
        {
            MessageBox(0, "Direct3D 9 extended mode is not supported in this configuration. "
                       + "Please use direct display mode, a different graphics API, or rebuild the application with a newer Unity version."
                       , "VR Configuration Warning", 0);
        }

        if (unsupportedExclusiveModeD3D11 && !display.isDirectMode && SystemInfo.graphicsDeviceVersion.Contains("Direct3D 11"))
        {
            MessageBox(0, "Direct3D 11 extended mode is not supported in this configuration. "
                       + "Please use direct display mode, a different graphics API, or rebuild the application with a newer Unity version."
                       , "VR Configuration Warning", 0);
        }
                #endif
    }
Ejemplo n.º 16
0
    private void Awake()
    {
        // Only allow one instance at runtime.
        if (instance != null)
        {
            enabled = false;
            DestroyImmediate(this);
            return;
        }

        instance = this;

        var netVersion = new System.Version(OVRPlugin.WrapperVersion);
        System.Version ovrVersion = new System.Version("0.0.0");
        var versionString = OVRPlugin.version;
        var success = false;
        try {
            ovrVersion = new System.Version(versionString);
            success = true;
        } catch (Exception e) {
            Debug.Log("Failed to parse Oculus version string \"" + versionString + "\" with message \"" + e.Message + "\".");
        }
        if (!success || netVersion > ovrVersion)
            Debug.LogWarning("Version check failed. Please make sure you are using Oculus runtime " +
                             OVRPlugin.WrapperVersion + " or newer.");

        Debug.Log("Unity v" + Application.unityVersion + ", " +
                  "Oculus Utilities v" + netVersion + ", " +
                  "OVRPlugin v" + ovrVersion + ".");

        #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
        if (SystemInfo.graphicsDeviceType != UnityEngine.Rendering.GraphicsDeviceType.Direct3D11)
            Debug.LogWarning("VR rendering requires Direct3D11. Your graphics device: " + SystemInfo.graphicsDeviceType);
        #endif

        // Detect whether this platform is a supported platform
        RuntimePlatform currPlatform = Application.platform;
        isSupportedPlatform |= currPlatform == RuntimePlatform.Android;
        //isSupportedPlatform |= currPlatform == RuntimePlatform.LinuxPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsPlayer;
        if (!isSupportedPlatform)
        {
            Debug.LogWarning("This platform is unsupported");
            return;
        }

        #if UNITY_ANDROID && !UNITY_EDITOR
        // We want to set up our touchpad messaging system
        OVRTouchpad.Create();

        // Turn off chromatic aberration by default to save texture bandwidth.
        chromatic = false;
        #endif

        InitVolumeController();

        if (display == null)
            display = new OVRDisplay();
        if (tracker == null)
            tracker = new OVRTracker();

        if (resetTrackerOnLoad)
            display.RecenterPose ();
    }
Ejemplo n.º 17
0
	private void Awake()
	{
		// Only allow one instance at runtime.
		if (instance != null)
		{
			enabled = false;
			DestroyImmediate(this);

			return;
		}

		instance = this;

#if !UNITY_ANDROID || UNITY_EDITOR
		var netVersion = new System.Version(Ovr.Hmd.OVR_VERSION_STRING);
		var ovrVersion = new System.Version(Ovr.Hmd.GetVersionString());
		if (netVersion > ovrVersion)
			Debug.LogWarning("Using an older version of LibOVR.");
#endif

        // Detect whether this platform is a supported platform
        RuntimePlatform currPlatform = Application.platform;
        isSupportedPlatform |= currPlatform == RuntimePlatform.Android;
        isSupportedPlatform |= currPlatform == RuntimePlatform.LinuxPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsPlayer;
        if (!isSupportedPlatform)
        {
            Debug.LogWarning("This platform is unsupported");
            return;
        }

#if UNITY_ANDROID && !UNITY_EDITOR
		Application.targetFrameRate = 60;
		// don't allow the app to run in the background
		Application.runInBackground = false;
		// Disable screen dimming
		Screen.sleepTimeout = SleepTimeout.NeverSleep;

		if (!androidJavaInit)
		{
			AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
			activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
			javaVrActivityClass = new AndroidJavaClass("com.oculusvr.vrlib.VrActivity");
			// Prepare for the RenderThreadInit()
			SetInitVariables(activity.GetRawObject(), javaVrActivityClass.GetRawClass());
			
			androidJavaInit = true;
		}

		// We want to set up our touchpad messaging system
		OVRTouchpad.Create();
		// This will trigger the init on the render thread
		InitRenderThread();
#else
		SetEditorPlay(Application.isEditor);
#endif

		if (display == null)
			display = new OVRDisplay();
		if (tracker == null)
			tracker = new OVRTracker();

		tracker.isEnabled = false;
		usePositionTracking = false;

		if (resetTrackerOnLoad)
			display.RecenterPose();

		// Except for D3D9, SDK rendering forces vsync unless you pass ovrHmdCap_NoVSync to Hmd.SetEnabledCaps().
		if (timeWarp)
		{
			bool useUnityVSync = SystemInfo.graphicsDeviceVersion.Contains("Direct3D 9");
			QualitySettings.vSyncCount = useUnityVSync ? 1 : 0;
		}

#if (UNITY_STANDALONE_WIN && (UNITY_4_6 || UNITY_4_5))
		bool unity_4_6 = false;
		bool unity_4_5_2 = false;
		bool unity_4_5_3 = false;
		bool unity_4_5_4 = false;
		bool unity_4_5_5 = false;

#if (UNITY_4_6)
		unity_4_6 = true;
#elif (UNITY_4_5_2)
		unity_4_5_2 = true;
#elif (UNITY_4_5_3)
		unity_4_5_3 = true;
#elif (UNITY_4_5_4)
		unity_4_5_4 = true;
#elif (UNITY_4_5_5)
		unity_4_5_5 = true;
#endif

		// Detect correct Unity releases which contain the fix for D3D11 exclusive mode.
		string version = Application.unityVersion;
		int releaseNumber;
		bool releaseNumberFound = Int32.TryParse(Regex.Match(version, @"\d+$").Value, out releaseNumber);

		// Exclusive mode was broken for D3D9 in Unity 4.5.2p2 - 4.5.4 and 4.6 builds prior to beta 21
		bool unsupportedExclusiveModeD3D9 = (unity_4_6 && version.Last(char.IsLetter) == 'b' && releaseNumberFound && releaseNumber < 21)
			|| (unity_4_5_2 && version.Last(char.IsLetter) == 'p' && releaseNumberFound && releaseNumber >= 2)
			|| (unity_4_5_3)
			|| (unity_4_5_4);

		// Exclusive mode was broken for D3D11 in Unity 4.5.2p2 - 4.5.5p2 and 4.6 builds prior to f1
		bool unsupportedExclusiveModeD3D11 = (unity_4_6 && version.Last(char.IsLetter) == 'b')
			|| (unity_4_5_2 && version.Last(char.IsLetter) == 'p' && releaseNumberFound && releaseNumber >= 2)
			|| (unity_4_5_3)
			|| (unity_4_5_4)
			|| (unity_4_5_5 && version.Last(char.IsLetter) == 'f')
			|| (unity_4_5_5 && version.Last(char.IsLetter) == 'p' && releaseNumberFound && releaseNumber < 3);

		if (unsupportedExclusiveModeD3D9 && !display.isDirectMode && SystemInfo.graphicsDeviceVersion.Contains("Direct3D 9"))
		{
			MessageBox(0, "Direct3D 9 extended mode is not supported in this configuration. "
				+ "Please use direct display mode, a different graphics API, or rebuild the application with a newer Unity version."
				, "VR Configuration Warning", 0);
		}

		if (unsupportedExclusiveModeD3D11 && !display.isDirectMode && SystemInfo.graphicsDeviceVersion.Contains("Direct3D 11"))
		{
			MessageBox(0, "Direct3D 11 extended mode is not supported in this configuration. "
				+ "Please use direct display mode, a different graphics API, or rebuild the application with a newer Unity version."
				, "VR Configuration Warning", 0);
		}
#endif
	}
Ejemplo n.º 18
0
    private void Awake()
    {
        // Only allow one instance at runtime.
        if (instance != null)
        {
            enabled = false;
            DestroyImmediate(this);
            return;
        }

        instance = this;

#if !UNITY_ANDROID || UNITY_EDITOR
        if (!ovrIsInitialized)
        {
            OVR_Initialize();
            OVRPluginEvent.Issue(RenderEventType.Initialize);

            ovrIsInitialized = true;
        }

        var netVersion = new System.Version(Ovr.Hmd.OVR_VERSION_STRING);
        var ovrVersion = new System.Version(Ovr.Hmd.GetVersionString());
        if (netVersion > ovrVersion)
        {
            Debug.LogWarning("Using an older version of LibOVR.");
        }
#endif

        // Detect whether this platform is a supported platform
        RuntimePlatform currPlatform = Application.platform;
        isSupportedPlatform |= currPlatform == RuntimePlatform.Android;
        isSupportedPlatform |= currPlatform == RuntimePlatform.LinuxPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsPlayer;
        if (!isSupportedPlatform)
        {
            Debug.LogWarning("This platform is unsupported");
            return;
        }

#if UNITY_ANDROID && !UNITY_EDITOR
        Application.targetFrameRate = 60;
        // don't allow the app to run in the background
        Application.runInBackground = false;
        // Disable screen dimming
        Screen.sleepTimeout = SleepTimeout.NeverSleep;

        if (!androidJavaInit)
        {
            AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            activity            = unityPlayer.GetStatic <AndroidJavaObject>("currentActivity");
            javaVrActivityClass = new AndroidJavaClass("com.oculusvr.vrlib.VrActivity");
            // Prepare for the RenderThreadInit()
            SetInitVariables(activity.GetRawObject(), javaVrActivityClass.GetRawClass());

            androidJavaInit = true;
        }

        // We want to set up our touchpad messaging system
//		OVRTouchpad.Create();
        // This will trigger the init on the render thread
        InitRenderThread();
#else
        SetEditorPlay(Application.isEditor);
#endif

        if (display == null)
        {
            display = new OVRDisplay();
        }
        if (tracker == null)
        {
            tracker = new OVRTracker();
        }

        if (resetTrackerOnLoad)
        {
            display.RecenterPose();
        }

        // Except for D3D9, SDK rendering forces vsync unless you pass ovrHmdCap_NoVSync to Hmd.SetEnabledCaps().
        if (timeWarp)
        {
            bool useUnityVSync = SystemInfo.graphicsDeviceVersion.Contains("Direct3D 9");
            QualitySettings.vSyncCount = useUnityVSync ? 1 : 0;
        }

#if (UNITY_STANDALONE_WIN && (UNITY_4_6 || UNITY_4_5))
        bool unity_4_6   = false;
        bool unity_4_5_2 = false;
        bool unity_4_5_3 = false;
        bool unity_4_5_4 = false;
        bool unity_4_5_5 = false;

#if (UNITY_4_6)
        unity_4_6 = true;
#elif (UNITY_4_5_2)
        unity_4_5_2 = true;
#elif (UNITY_4_5_3)
        unity_4_5_3 = true;
#elif (UNITY_4_5_4)
        unity_4_5_4 = true;
#elif (UNITY_4_5_5)
        unity_4_5_5 = true;
#endif

        // Detect correct Unity releases which contain the fix for D3D11 exclusive mode.
        string version = Application.unityVersion;
        int    releaseNumber;
        bool   releaseNumberFound = Int32.TryParse(Regex.Match(version, @"\d+$").Value, out releaseNumber);

        // Exclusive mode was broken for D3D9 in Unity 4.5.2p2 - 4.5.4 and 4.6 builds prior to beta 21
        bool unsupportedExclusiveModeD3D9 = (unity_4_6 && version.Last(char.IsLetter) == 'b' && releaseNumberFound && releaseNumber < 21) ||
                                            (unity_4_5_2 && version.Last(char.IsLetter) == 'p' && releaseNumberFound && releaseNumber >= 2) ||
                                            (unity_4_5_3) ||
                                            (unity_4_5_4);

        // Exclusive mode was broken for D3D11 in Unity 4.5.2p2 - 4.5.5p2 and 4.6 builds prior to f1
        bool unsupportedExclusiveModeD3D11 = (unity_4_6 && version.Last(char.IsLetter) == 'b') ||
                                             (unity_4_5_2 && version.Last(char.IsLetter) == 'p' && releaseNumberFound && releaseNumber >= 2) ||
                                             (unity_4_5_3) ||
                                             (unity_4_5_4) ||
                                             (unity_4_5_5 && version.Last(char.IsLetter) == 'f') ||
                                             (unity_4_5_5 && version.Last(char.IsLetter) == 'p' && releaseNumberFound && releaseNumber < 3);

        if (unsupportedExclusiveModeD3D9 && !display.isDirectMode && SystemInfo.graphicsDeviceVersion.Contains("Direct3D 9"))
        {
            MessageBox(0, "Direct3D 9 extended mode is not supported in this configuration. "
                       + "Please use direct display mode, a different graphics API, or rebuild the application with a newer Unity version."
                       , "VR Configuration Warning", 0);
        }

        if (unsupportedExclusiveModeD3D11 && !display.isDirectMode && SystemInfo.graphicsDeviceVersion.Contains("Direct3D 11"))
        {
            MessageBox(0, "Direct3D 11 extended mode is not supported in this configuration. "
                       + "Please use direct display mode, a different graphics API, or rebuild the application with a newer Unity version."
                       , "VR Configuration Warning", 0);
        }
#endif
    }
Ejemplo n.º 19
0
	private void Awake()
	{
		// Only allow one instance at runtime.
		if (instance != null)
		{
			enabled = false;
			DestroyImmediate(this);
			return;
		}

		instance = this;

#if !UNITY_ANDROID || UNITY_EDITOR
		if (!ovrIsInitialized)
		{
			OVR_Initialize();
			OVRPluginEvent.Issue(RenderEventType.Initialize);

			ovrIsInitialized = true;
		}

		var netVersion = new System.Version(Ovr.Hmd.OVR_VERSION_STRING);
		var ovrVersion = new System.Version(Ovr.Hmd.GetVersionString());
		if (netVersion > ovrVersion)
			Debug.LogWarning("Using an older version of LibOVR.");
#endif

        // Detect whether this platform is a supported platform
        RuntimePlatform currPlatform = Application.platform;
        isSupportedPlatform |= currPlatform == RuntimePlatform.Android;
        isSupportedPlatform |= currPlatform == RuntimePlatform.LinuxPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsPlayer;
        if (!isSupportedPlatform)
        {
            Debug.LogWarning("This platform is unsupported");
            return;
        }

#if UNITY_ANDROID && !UNITY_EDITOR
		// don't allow the application to run if orientation is not landscape left.
		if (Screen.orientation != ScreenOrientation.LandscapeLeft)
		{
			Debug.LogError("********************************************************************************\n");
			Debug.LogError("***** Default screen orientation must be set to landscape left for VR.\n" +
			               "***** Stopping application.\n");
			Debug.LogError("********************************************************************************\n");

			Debug.Break();
			Application.Quit();
		}

		// don't enable gyro, it is not used and triggers expensive display calls
		if (Input.gyro.enabled)
		{
			Debug.LogError("*** Auto-disabling Gyroscope ***");
			Input.gyro.enabled = false;
		}
		
		// NOTE: On Adreno Lollipop, it is an error to have antiAliasing set on the
		// main window surface with front buffer rendering enabled. The view will
		// render black.
		// On Adreno KitKat, some tiling control modes will cause the view to render
		// black.
		if (QualitySettings.antiAliasing > 1)
		{
			Debug.LogError("*** Antialiasing must be disabled for Gear VR ***");
		}

		// we sync in the TimeWarp, so we don't want unity
		// syncing elsewhere
		QualitySettings.vSyncCount = 0;

		// try to render at 60fps
		Application.targetFrameRate = 60;
		// don't allow the app to run in the background
		Application.runInBackground = false;
		// Disable screen dimming
		Screen.sleepTimeout = SleepTimeout.NeverSleep;

		if (!androidJavaInit)
		{
			AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
			activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
			javaVrActivityClass = new AndroidJavaClass("com.oculusvr.vrlib.VrActivity");
			// Prepare for the RenderThreadInit()
			SetInitVariables(activity.GetRawObject(), javaVrActivityClass.GetRawClass());

#if !INHIBIT_ENTITLEMENT_CHECK
			AndroidJavaObject entitlementChecker = new AndroidJavaObject("com.oculus.svclib.OVREntitlementChecker");
			entitlementChecker.CallStatic("doAutomatedCheck", activity);
#else
			Debug.Log( "Inhibiting Entitlement Check!" );
#endif

			androidJavaInit = true;
		}

		// We want to set up our touchpad messaging system
		OVRTouchpad.Create();

		InitVolumeController();
#else
		SetEditorPlay(Application.isEditor);
#endif

		prevEyeTextureAntiAliasing = OVRManager.instance.eyeTextureAntiAliasing;
		prevEyeTextureDepth = OVRManager.instance.eyeTextureDepth;
		prevEyeTextureFormat = OVRManager.instance.eyeTextureFormat;
        prevNativeTextureScale = OVRManager.instance.nativeTextureScale;
        prevVirtualTextureScale = OVRManager.instance.virtualTextureScale;
        prevMonoscopic = OVRManager.instance.monoscopic;
        prevHdr = OVRManager.instance.hdr;

		if (display == null)
			display = new OVRDisplay();
		if (tracker == null)
			tracker = new OVRTracker();

		if (resetTrackerOnLoad)
			display.RecenterPose();

#if !UNITY_ANDROID || UNITY_EDITOR
		// Except for D3D9, SDK rendering forces vsync unless you pass ovrHmdCap_NoVSync to Hmd.SetEnabledCaps().
		if (timeWarp)
		{
			bool useUnityVSync = SystemInfo.graphicsDeviceVersion.Contains("Direct3D 9");
			QualitySettings.vSyncCount = useUnityVSync ? 1 : 0;
		}
#endif

#if (UNITY_STANDALONE_WIN && (UNITY_4_6 || UNITY_4_5))
		bool unity_4_6 = false;
		bool unity_4_5_2 = false;
		bool unity_4_5_3 = false;
		bool unity_4_5_4 = false;
		bool unity_4_5_5 = false;

#if (UNITY_4_6)
		unity_4_6 = true;
#elif (UNITY_4_5_2)
		unity_4_5_2 = true;
#elif (UNITY_4_5_3)
		unity_4_5_3 = true;
#elif (UNITY_4_5_4)
		unity_4_5_4 = true;
#elif (UNITY_4_5_5)
		unity_4_5_5 = true;
#endif

		// Detect correct Unity releases which contain the fix for D3D11 exclusive mode.
		string version = Application.unityVersion;
		int releaseNumber;
		bool releaseNumberFound = Int32.TryParse(Regex.Match(version, @"\d+$").Value, out releaseNumber);

		// Exclusive mode was broken for D3D9 in Unity 4.5.2p2 - 4.5.4 and 4.6 builds prior to beta 21
		bool unsupportedExclusiveModeD3D9 = (unity_4_6 && version.Last(char.IsLetter) == 'b' && releaseNumberFound && releaseNumber < 21)
			|| (unity_4_5_2 && version.Last(char.IsLetter) == 'p' && releaseNumberFound && releaseNumber >= 2)
			|| (unity_4_5_3)
			|| (unity_4_5_4);

		// Exclusive mode was broken for D3D11 in Unity 4.5.2p2 - 4.5.5p2 and 4.6 builds prior to f1
		bool unsupportedExclusiveModeD3D11 = (unity_4_6 && version.Last(char.IsLetter) == 'b')
			|| (unity_4_5_2 && version.Last(char.IsLetter) == 'p' && releaseNumberFound && releaseNumber >= 2)
			|| (unity_4_5_3)
			|| (unity_4_5_4)
			|| (unity_4_5_5 && version.Last(char.IsLetter) == 'f')
			|| (unity_4_5_5 && version.Last(char.IsLetter) == 'p' && releaseNumberFound && releaseNumber < 3);

		if (unsupportedExclusiveModeD3D9 && !display.isDirectMode && SystemInfo.graphicsDeviceVersion.Contains("Direct3D 9"))
		{
			MessageBox(0, "Direct3D 9 extended mode is not supported in this configuration. "
				+ "Please use direct display mode, a different graphics API, or rebuild the application with a newer Unity version."
				, "VR Configuration Warning", 0);
		}

		if (unsupportedExclusiveModeD3D11 && !display.isDirectMode && SystemInfo.graphicsDeviceVersion.Contains("Direct3D 11"))
		{
			MessageBox(0, "Direct3D 11 extended mode is not supported in this configuration. "
				+ "Please use direct display mode, a different graphics API, or rebuild the application with a newer Unity version."
				, "VR Configuration Warning", 0);
		}
#endif
	}
Ejemplo n.º 20
0
    private void Awake()
    {
        // Only allow one instance at runtime.
        if (instance != null)
        {
            enabled = false;
            DestroyImmediate(this);
            return;
        }

        instance = this;

        System.Version netVersion = OVRPlugin.wrapperVersion;
        System.Version ovrVersion = OVRPlugin.version;

        //Debug.Log("Unity v" + Application.unityVersion + ", " +
        //          "Oculus Utilities v" + netVersion + ", " +
        //          "OVRPlugin v" + ovrVersion + ".");

#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
        if (SystemInfo.graphicsDeviceType != UnityEngine.Rendering.GraphicsDeviceType.Direct3D11)
        {
            Debug.LogWarning("VR rendering requires Direct3D11. Your graphics device: " + SystemInfo.graphicsDeviceType);
        }
#endif

        // Detect whether this platform is a supported platform
        RuntimePlatform currPlatform = Application.platform;
        isSupportedPlatform |= currPlatform == RuntimePlatform.Android;
        //isSupportedPlatform |= currPlatform == RuntimePlatform.LinuxPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsPlayer;
        if (!isSupportedPlatform)
        {
            Debug.LogWarning("This platform is unsupported");
            return;
        }

#if UNITY_ANDROID && !UNITY_EDITOR
        // We want to set up our touchpad messaging system
        OVRTouchpad.Create();

        // Turn off chromatic aberration by default to save texture bandwidth.
        chromatic = false;
#endif

        InitVolumeController();

        if (display == null)
        {
            display = new OVRDisplay();
        }
        if (tracker == null)
        {
            tracker = new OVRTracker();
        }
        if (input == null)
        {
            input = new OVRInput();
        }

        if (resetTrackerOnLoad)
        {
            display.RecenterPose();
        }
    }
Ejemplo n.º 21
0
    private void Awake()
    {
        // Only allow one instance at runtime.
        if (instance != null)
        {
            enabled = false;
            DestroyImmediate(this);
            return;
        }

        instance = this;

#if !UNITY_ANDROID || UNITY_EDITOR
        var netVersion = new System.Version(Ovr.Hmd.OVR_VERSION_STRING);
        var ovrVersion = new System.Version(Ovr.Hmd.GetVersionString());
        if (netVersion > ovrVersion)
        {
            Debug.LogWarning("Using an older version of LibOVR.");
        }
#endif

        // Detect whether this platform is a supported platform
        RuntimePlatform currPlatform = Application.platform;
        isSupportedPlatform |= currPlatform == RuntimePlatform.Android;
        isSupportedPlatform |= currPlatform == RuntimePlatform.LinuxPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsPlayer;
        if (!isSupportedPlatform)
        {
            Debug.LogWarning("This platform is unsupported");
            return;
        }

#if UNITY_ANDROID && !UNITY_EDITOR
        Application.targetFrameRate = 60;
        // don't allow the app to run in the background
        Application.runInBackground = false;
        // Disable screen dimming
        Screen.sleepTimeout = SleepTimeout.NeverSleep;

        if (!androidJavaInit)
        {
            AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            activity            = unityPlayer.GetStatic <AndroidJavaObject>("currentActivity");
            javaVrActivityClass = new AndroidJavaClass("com.oculusvr.vrlib.VrActivity");
            // Prepare for the RenderThreadInit()
            SetInitVariables(activity.GetRawObject(), javaVrActivityClass.GetRawClass());

            androidJavaInit = true;
        }

        // We want to set up our touchpad messaging system
        OVRTouchpad.Create();
        // This will trigger the init on the render thread
        InitRenderThread();
#else
        SetEditorPlay(Application.isEditor);
#endif

        display = new OVRDisplay();
        tracker = new OVRTracker();

        // Except for D3D9, SDK rendering forces vsync unless you pass ovrHmdCap_NoVSync to Hmd.SetEnabledCaps().
        if (timeWarp)
        {
            bool useUnityVSync = SystemInfo.graphicsDeviceVersion.Contains("Direct3D 9");
            QualitySettings.vSyncCount = useUnityVSync ? 1 : 0;
        }
    }