Example #1
0
        private void doTheOvrHack()
        {
            if (oVRManager == null)
            {
                // hack the OVRManager
                oVRManager = new OVRManager();
                typeof(OVRManager).GetProperty("instance").SetValue(null, oVRManager, null);


                bool flag  = (bool)typeof(OVRManager).GetMethod("LoadMixedRealityCaptureConfigurationFileFromCmd", BindingFlags.NonPublic | BindingFlags.Static).Invoke(null, null);
                bool flag2 = (bool)typeof(OVRManager).GetMethod("CreateMixedRealityCaptureConfigurationFileFromCmd", BindingFlags.NonPublic | BindingFlags.Static).Invoke(null, null);
                if (flag || flag2)
                {
                    Console.WriteLine("Loading mrc.config...");
                    OVRMixedRealityCaptureSettings oVRMixedRealityCaptureSettings = ScriptableObject.CreateInstance <OVRMixedRealityCaptureSettings>();
                    oVRMixedRealityCaptureSettings.ReadFrom(oVRManager);
                    if (flag)
                    {
                        oVRMixedRealityCaptureSettings.CombineWithConfigurationFile();
                        oVRMixedRealityCaptureSettings.ApplyTo(oVRManager);
                    }
                    if (flag2)
                    {
                        oVRMixedRealityCaptureSettings.WriteToConfigurationFile();
                    }
                    Object.Destroy(oVRMixedRealityCaptureSettings);
                }
                ;

                if ((bool)typeof(OVRManager).GetMethod("UseDirectCompositionFromCmd", BindingFlags.NonPublic | BindingFlags.Static).Invoke(null, null))
                {
                    oVRManager.compositionMethod = OVRManager.CompositionMethod.Direct;
                }
                if ((bool)typeof(OVRManager).GetMethod("UseExternalCompositionFromCmd", BindingFlags.NonPublic | BindingFlags.Static).Invoke(null, null))
                {
                    oVRManager.compositionMethod = OVRManager.CompositionMethod.External;
                }
                Debug.LogWarning("OVR: CompositionMethod : " + oVRManager.compositionMethod);
            }
        }
Example #2
0
    private void Awake()
    {
        if (OVRManager.instance != null)
        {
            base.enabled = false;
            UnityEngine.Object.DestroyImmediate(this);
            return;
        }
        OVRManager.instance = this;
        Debug.Log(string.Concat(new object[]
        {
            "Unity v",
            Application.unityVersion,
            ", Oculus Utilities v",
            OVRPlugin.wrapperVersion,
            ", OVRPlugin v",
            OVRPlugin.version,
            ", SDK v",
            OVRPlugin.nativeSDKVersion,
            "."
        }));
        string text = GraphicsDeviceType.Direct3D11.ToString() + ", " + GraphicsDeviceType.Direct3D12.ToString();

        if (!text.Contains(SystemInfo.graphicsDeviceType.ToString()))
        {
            Debug.LogWarning("VR rendering requires one of the following device types: (" + text + "). Your graphics device: " + SystemInfo.graphicsDeviceType.ToString());
        }
        RuntimePlatform platform = Application.platform;

        this.isSupportedPlatform |= (platform == RuntimePlatform.Android);
        this.isSupportedPlatform |= (platform == RuntimePlatform.OSXEditor);
        this.isSupportedPlatform |= (platform == RuntimePlatform.OSXPlayer);
        this.isSupportedPlatform |= (platform == RuntimePlatform.WindowsEditor);
        this.isSupportedPlatform |= (platform == RuntimePlatform.WindowsPlayer);
        if (!this.isSupportedPlatform)
        {
            Debug.LogWarning("This platform is unsupported");
            return;
        }
        this.enableMixedReality = false;
        bool flag  = OVRManager.LoadMixedRealityCaptureConfigurationFileFromCmd();
        bool flag2 = OVRManager.CreateMixedRealityCaptureConfigurationFileFromCmd();

        if (flag || flag2)
        {
            OVRMixedRealityCaptureSettings ovrmixedRealityCaptureSettings = ScriptableObject.CreateInstance <OVRMixedRealityCaptureSettings>();
            ovrmixedRealityCaptureSettings.ReadFrom(this);
            if (flag)
            {
                ovrmixedRealityCaptureSettings.CombineWithConfigurationFile();
                ovrmixedRealityCaptureSettings.ApplyTo(this);
            }
            if (flag2)
            {
                ovrmixedRealityCaptureSettings.WriteToConfigurationFile();
            }
            UnityEngine.Object.Destroy(ovrmixedRealityCaptureSettings);
        }
        if (OVRManager.MixedRealityEnabledFromCmd())
        {
            this.enableMixedReality = true;
        }
        if (this.enableMixedReality)
        {
            Debug.Log("OVR: Mixed Reality mode enabled");
            if (OVRManager.UseDirectCompositionFromCmd())
            {
                this.compositionMethod = OVRManager.CompositionMethod.Direct;
            }
            if (OVRManager.UseExternalCompositionFromCmd())
            {
                this.compositionMethod = OVRManager.CompositionMethod.External;
            }
            Debug.Log("OVR: CompositionMethod : " + this.compositionMethod);
        }
        if (this.enableAdaptiveResolution && !OVRManager.IsAdaptiveResSupportedByEngine())
        {
            this.enableAdaptiveResolution = false;
            Debug.LogError("Your current Unity Engine " + Application.unityVersion + " might have issues to support adaptive resolution, please disable it under OVRManager");
        }
        this.Initialize();
        if (this.resetTrackerOnLoad)
        {
            OVRManager.display.RecenterPose();
        }
        OVRPlugin.occlusionMesh = true;
    }
Example #3
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
        if (IsUnityAlphaOrBetaVersion())
        {
            Debug.LogWarning(UnityAlphaOrBetaVersionWarningMessage);
        }
#endif

#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
        var supportedTypes =
            UnityEngine.Rendering.GraphicsDeviceType.Direct3D11.ToString() + ", " +
            UnityEngine.Rendering.GraphicsDeviceType.Direct3D12.ToString();

        if (!supportedTypes.Contains(SystemInfo.graphicsDeviceType.ToString()))
        {
            Debug.LogWarning("VR rendering requires one of the following device types: (" + supportedTypes + "). Your graphics device: " + SystemInfo.graphicsDeviceType.ToString());
        }
#endif

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

#if UNITY_ANDROID && !UNITY_EDITOR
        // Turn off chromatic aberration by default to save texture bandwidth.
        chromatic = false;
#endif

#if UNITY_STANDALONE_WIN && !UNITY_EDITOR
        enableMixedReality = false;                     // we should never start the standalone game in MxR mode, unless the command-line parameter is provided
#endif

#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
        bool loadMrcConfig   = LoadMixedRealityCaptureConfigurationFileFromCmd();
        bool createMrcConfig = CreateMixedRealityCaptureConfigurationFileFromCmd();

        if (loadMrcConfig || createMrcConfig)
        {
            OVRMixedRealityCaptureSettings mrcSettings = ScriptableObject.CreateInstance <OVRMixedRealityCaptureSettings>();
            mrcSettings.ReadFrom(this);
            if (loadMrcConfig)
            {
                mrcSettings.CombineWithConfigurationFile();
                mrcSettings.ApplyTo(this);
            }
            if (createMrcConfig)
            {
                mrcSettings.WriteToConfigurationFile();
            }
            ScriptableObject.Destroy(mrcSettings);
        }

        if (MixedRealityEnabledFromCmd())
        {
            enableMixedReality = true;
        }

        if (enableMixedReality)
        {
            Debug.Log("OVR: Mixed Reality mode enabled");
            if (UseDirectCompositionFromCmd())
            {
                compositionMethod = CompositionMethod.Direct;
            }
            if (UseExternalCompositionFromCmd())
            {
                compositionMethod = CompositionMethod.External;
            }
            Debug.Log("OVR: CompositionMethod : " + compositionMethod);
        }
#endif

#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
        if (enableAdaptiveResolution && !OVRManager.IsAdaptiveResSupportedByEngine())
        {
            enableAdaptiveResolution = false;
            UnityEngine.Debug.LogError("Your current Unity Engine " + Application.unityVersion + " might have issues to support adaptive resolution, please disable it under OVRManager");
        }
#endif

        Initialize();

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

#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
        // Force OcculusionMesh on all the time, you can change the value to false if you really need it be off for some reasons,
        // be aware there are performance drops if you don't use occlusionMesh.
        OVRPlugin.occlusionMesh = true;
#endif
    }
Example #4
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
        var supportedTypes =
            UnityEngine.Rendering.GraphicsDeviceType.Direct3D11.ToString() + ", " +
            UnityEngine.Rendering.GraphicsDeviceType.Direct3D12.ToString();

        if (!supportedTypes.Contains(SystemInfo.graphicsDeviceType.ToString()))
        {
            Debug.LogWarning("VR rendering requires one of the following device types: (" + supportedTypes + "). Your graphics device: " + SystemInfo.graphicsDeviceType.ToString());
        }
#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 UNITY_STANDALONE_WIN && !UNITY_EDITOR
        enableMixedReality = false;                     // we should never start the standalone game in MxR mode, unless the command-line parameter is provided
#endif

#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
        bool loadMrcConfig   = LoadMixedRealityCaptureConfigurationFileFromCmd();
        bool createMrcConfig = CreateMixedRealityCaptureConfigurationFileFromCmd();

        if (loadMrcConfig || createMrcConfig)
        {
            OVRMixedRealityCaptureSettings mrcSettings = ScriptableObject.CreateInstance <OVRMixedRealityCaptureSettings>();
            mrcSettings.ReadFrom(this);
            if (loadMrcConfig)
            {
                mrcSettings.CombineWithConfigurationFile();
                mrcSettings.ApplyTo(this);
            }
            if (createMrcConfig)
            {
                mrcSettings.WriteToConfigurationFile();
            }
            ScriptableObject.Destroy(mrcSettings);
        }

        if (MixedRealityEnabledFromCmd())
        {
            enableMixedReality = true;
        }

        if (enableMixedReality)
        {
            Debug.Log("OVR: Mixed Reality mode enabled");
            if (UseDirectCompositionFromCmd())
            {
                compositionMethod = CompositionMethod.Direct;
            }
            if (UseExternalCompositionFromCmd())
            {
                compositionMethod = CompositionMethod.External;
            }
            Debug.Log("OVR: CompositionMethod : " + compositionMethod);
        }
#endif

        Initialize();

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

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