Exemple #1
0
    // Token: 0x060000B6 RID: 182 RVA: 0x0000839C File Offset: 0x0000659C
    private global::System.Collections.IEnumerator RenderLoop()
    {
        for (;;)
        {
            yield return(new global::UnityEngine.WaitForEndOfFrame());

            bool pauseRendering = global::SteamVR_Render.pauseRendering;
            if (!pauseRendering)
            {
                global::Valve.VR.CVRCompositor compositor = global::Valve.VR.OpenVR.Compositor;
                bool flag = compositor != null;
                if (flag)
                {
                    bool flag2 = !compositor.CanRenderScene();
                    if (flag2)
                    {
                        continue;
                    }
                    compositor.SetTrackingSpace(this.trackingSpace);
                    global::SteamVR_Utils.QueueEventOnRenderThread(201510020);
                    global::SteamVR.Unity.EventWriteString("[UnityMain] GetNativeTexturePtr - Begin");
                    global::SteamVR_Camera.GetSceneTexture(this.cameras[0].GetComponent <global::UnityEngine.Camera>().allowHDR).GetNativeTexturePtr();
                    global::SteamVR.Unity.EventWriteString("[UnityMain] GetNativeTexturePtr - End");
                    compositor.GetLastPoses(this.poses, this.gamePoses);
                    global::SteamVR_Utils.Event.Send("new_poses", new object[]
                    {
                        this.poses
                    });
                    global::SteamVR_Utils.Event.Send("new_poses_applied", global::System.Array.Empty <object>());
                }
                global::SteamVR_Overlay overlay = global::SteamVR_Overlay.instance;
                bool flag3 = overlay != null;
                if (flag3)
                {
                    overlay.UpdateOverlay();
                }
                this.RenderExternalCamera();
                global::SteamVR vr = global::SteamVR.instance;
                this.RenderEye(vr, global::Valve.VR.EVREye.Eye_Left);
                this.RenderEye(vr, global::Valve.VR.EVREye.Eye_Right);
                foreach (global::SteamVR_Camera c in this.cameras)
                {
                    c.transform.localPosition = global::UnityEngine.Vector3.zero;
                    c.transform.localRotation = global::UnityEngine.Quaternion.identity;
                    c = null;
                }
                global::SteamVR_Camera[] array = null;
                bool flag4 = this.cameraMask != null;
                if (flag4)
                {
                    this.cameraMask.Clear();
                }
                compositor = null;
                overlay    = null;
                vr         = null;
            }
        }
        yield break;
    }
    // Token: 0x0600006E RID: 110 RVA: 0x00004FE8 File Offset: 0x000031E8
    public static void View(global::UnityEngine.Color newColor, float duration)
    {
        global::Valve.VR.CVRCompositor compositor = global::Valve.VR.OpenVR.Compositor;
        bool flag = compositor != null;

        if (flag)
        {
            compositor.FadeToColor(duration, newColor.r, newColor.g, newColor.b, newColor.a, false);
        }
    }
    // Token: 0x060000D8 RID: 216 RVA: 0x00009AF8 File Offset: 0x00007CF8
    public static void ClearOverride()
    {
        global::Valve.VR.CVRCompositor compositor = global::Valve.VR.OpenVR.Compositor;
        bool flag = compositor != null;

        if (flag)
        {
            compositor.ClearSkyboxOverride();
        }
    }
Exemple #4
0
    // Token: 0x060000F1 RID: 241 RVA: 0x0000A6AC File Offset: 0x000088AC
    private void OnPreCull()
    {
        global::Valve.VR.CVRCompositor compositor = global::Valve.VR.OpenVR.Compositor;
        bool flag = compositor != null;

        if (flag)
        {
            global::SteamVR_Render instance = global::SteamVR_Render.instance;
            compositor.GetLastPoses(instance.poses, instance.gamePoses);
            global::SteamVR_Utils.Event.Send("new_poses", new object[]
            {
                instance.poses
            });
            global::SteamVR_Utils.Event.Send("new_poses_applied", global::System.Array.Empty <object>());
        }
    }
    // Token: 0x060000D7 RID: 215 RVA: 0x000099E4 File Offset: 0x00007BE4
    public static void SetOverride(global::UnityEngine.Texture front = null, global::UnityEngine.Texture back = null, global::UnityEngine.Texture left = null, global::UnityEngine.Texture right = null, global::UnityEngine.Texture top = null, global::UnityEngine.Texture bottom = null)
    {
        global::Valve.VR.CVRCompositor compositor = global::Valve.VR.OpenVR.Compositor;
        bool flag = compositor != null;

        if (flag)
        {
            global::UnityEngine.Texture[] array = new global::UnityEngine.Texture[]
            {
                front,
                back,
                left,
                right,
                top,
                bottom
            };
            global::Valve.VR.Texture_t[] array2 = new global::Valve.VR.Texture_t[6];
            for (int i = 0; i < 6; i++)
            {
                array2[i].handle      = ((array[i] != null) ? array[i].GetNativeTexturePtr() : global::System.IntPtr.Zero);
                array2[i].eType       = global::SteamVR.instance.graphicsAPI;
                array2[i].eColorSpace = global::Valve.VR.EColorSpace.Auto;
            }
            global::Valve.VR.EVRCompositorError evrcompositorError = compositor.SetSkyboxOverride(array2);
            bool flag2 = evrcompositorError > global::Valve.VR.EVRCompositorError.None;
            if (flag2)
            {
                global::UnityEngine.Debug.LogError("Failed to set skybox override with error: " + evrcompositorError.ToString());
                bool flag3 = evrcompositorError == global::Valve.VR.EVRCompositorError.TextureIsOnWrongDevice;
                if (flag3)
                {
                    global::UnityEngine.Debug.Log("Set your graphics driver to use the same video card as the headset is plugged into for Unity.");
                }
                else
                {
                    bool flag4 = evrcompositorError == global::Valve.VR.EVRCompositorError.TextureUsesUnsupportedFormat;
                    if (flag4)
                    {
                        global::UnityEngine.Debug.Log("Ensure skybox textures are not compressed and have no mipmaps.");
                    }
                }
            }
        }
    }
    // Token: 0x06000088 RID: 136 RVA: 0x0000657D File Offset: 0x0000477D
    private global::System.Collections.IEnumerator LoadLevel()
    {
        bool flag = this.loadingScreen != null && this.loadingScreenDistance > 0f;

        if (flag)
        {
            global::SteamVR_Controller.Device hmd = global::SteamVR_Controller.Input(0);
            while (!hmd.hasTracking)
            {
                yield return(null);
            }
            global::SteamVR_Utils.RigidTransform tloading = hmd.transform;
            tloading.rot  = global::UnityEngine.Quaternion.Euler(0f, tloading.rot.eulerAngles.y, 0f);
            tloading.pos += tloading.rot * new global::UnityEngine.Vector3(0f, 0f, this.loadingScreenDistance);
            global::UnityEngine.Transform t = (this.loadingScreenTransform != null) ? this.loadingScreenTransform : base.transform;
            t.position = tloading.pos;
            t.rotation = tloading.rot;
            hmd        = null;
            tloading   = default(global::SteamVR_Utils.RigidTransform);
            t          = null;
        }
        global::SteamVR_LoadLevel._active = this;
        global::SteamVR_Utils.Event.Send("loading", new object[]
        {
            true
        });
        bool flag2 = this.loadingScreenFadeInTime > 0f;

        if (flag2)
        {
            this.fadeRate = 1f / this.loadingScreenFadeInTime;
        }
        else
        {
            this.alpha = 1f;
        }
        global::Valve.VR.CVROverlay overlay = global::Valve.VR.OpenVR.Overlay;
        bool flag3 = this.loadingScreen != null && overlay != null;

        if (flag3)
        {
            this.loadingScreenOverlayHandle = this.GetOverlayHandle("loadingScreen", (this.loadingScreenTransform != null) ? this.loadingScreenTransform : base.transform, this.loadingScreenWidthInMeters);
            bool flag4 = this.loadingScreenOverlayHandle > 0UL;
            if (flag4)
            {
                global::Valve.VR.Texture_t texture = default(global::Valve.VR.Texture_t);
                texture.handle      = this.loadingScreen.GetNativeTexturePtr();
                texture.eType       = global::SteamVR.instance.graphicsAPI;
                texture.eColorSpace = global::Valve.VR.EColorSpace.Auto;
                overlay.SetOverlayTexture(this.loadingScreenOverlayHandle, ref texture);
            }
        }
        bool fadedForeground = false;

        global::SteamVR_Utils.Event.Send("loading_fade_out", new object[]
        {
            this.fadeOutTime
        });
        global::Valve.VR.CVRCompositor compositor = global::Valve.VR.OpenVR.Compositor;
        bool flag5 = compositor != null;

        if (flag5)
        {
            bool flag6 = this.front != null;
            if (flag6)
            {
                global::SteamVR_Skybox.SetOverride(this.front, this.back, this.left, this.right, this.top, this.bottom);
                compositor.FadeGrid(this.fadeOutTime, true);
                yield return(new global::UnityEngine.WaitForSeconds(this.fadeOutTime));
            }
            else
            {
                bool flag7 = this.backgroundColor != global::UnityEngine.Color.clear;
                if (flag7)
                {
                    bool flag8 = this.showGrid;
                    if (flag8)
                    {
                        compositor.FadeToColor(0f, this.backgroundColor.r, this.backgroundColor.g, this.backgroundColor.b, this.backgroundColor.a, true);
                        compositor.FadeGrid(this.fadeOutTime, true);
                        yield return(new global::UnityEngine.WaitForSeconds(this.fadeOutTime));
                    }
                    else
                    {
                        compositor.FadeToColor(this.fadeOutTime, this.backgroundColor.r, this.backgroundColor.g, this.backgroundColor.b, this.backgroundColor.a, false);
                        yield return(new global::UnityEngine.WaitForSeconds(this.fadeOutTime + 0.1f));

                        compositor.FadeGrid(0f, true);
                        fadedForeground = true;
                    }
                }
            }
        }
        global::SteamVR_Render.pauseRendering = true;
        while (this.alpha < 1f)
        {
            yield return(null);
        }
        base.transform.parent = null;
        global::UnityEngine.Object.DontDestroyOnLoad(base.gameObject);
        bool flag9 = this.loadExternalApp;

        if (flag9)
        {
            global::UnityEngine.Debug.Log("Launching external application...");
            global::Valve.VR.CVRApplications applications = global::Valve.VR.OpenVR.Applications;
            bool flag10 = applications == null;
            if (flag10)
            {
                global::UnityEngine.Debug.Log("Failed to get OpenVR.Applications interface!");
            }
            else
            {
                string workingDirectory = global::System.IO.Directory.GetCurrentDirectory();
                string fullPath         = global::System.IO.Path.Combine(workingDirectory, this.externalAppPath);
                global::UnityEngine.Debug.Log("LaunchingInternalProcess");
                global::UnityEngine.Debug.Log("ExternalAppPath = " + this.externalAppPath);
                global::UnityEngine.Debug.Log("FullPath = " + fullPath);
                global::UnityEngine.Debug.Log("ExternalAppArgs = " + this.externalAppArgs);
                global::UnityEngine.Debug.Log("WorkingDirectory = " + workingDirectory);
                global::UnityEngine.Debug.Log("LaunchInternalProcessError: " + applications.LaunchInternalProcess(fullPath, this.externalAppArgs, workingDirectory).ToString());
                global::System.Diagnostics.Process.GetCurrentProcess().Kill();
                workingDirectory = null;
                fullPath         = null;
            }
            applications = null;
        }
        else
        {
            global::UnityEngine.SceneManagement.LoadSceneMode mode = this.loadAdditive ? 1 : 0;
            bool flag11 = this.loadAsync;
            if (flag11)
            {
                global::UnityEngine.Application.backgroundLoadingPriority = 0;
                this.async = global::UnityEngine.SceneManagement.SceneManager.LoadSceneAsync(this.levelName, mode);
                while (!this.async.isDone)
                {
                    yield return(null);
                }
            }
            else
            {
                global::UnityEngine.SceneManagement.SceneManager.LoadScene(this.levelName, mode);
            }
        }
        yield return(null);

        global::System.GC.Collect();
        yield return(null);

        global::UnityEngine.Shader.WarmupAllShaders();
        yield return(new global::UnityEngine.WaitForSeconds(this.postLoadSettleTime));

        global::SteamVR_Render.pauseRendering = false;
        bool flag12 = this.loadingScreenFadeOutTime > 0f;

        if (flag12)
        {
            this.fadeRate = -1f / this.loadingScreenFadeOutTime;
        }
        else
        {
            this.alpha = 0f;
        }
        global::SteamVR_Utils.Event.Send("loading_fade_in", new object[]
        {
            this.fadeInTime
        });
        bool flag13 = compositor != null;

        if (flag13)
        {
            bool flag14 = fadedForeground;
            if (flag14)
            {
                compositor.FadeGrid(0f, false);
                compositor.FadeToColor(this.fadeInTime, 0f, 0f, 0f, 0f, false);
                yield return(new global::UnityEngine.WaitForSeconds(this.fadeInTime));
            }
            else
            {
                compositor.FadeGrid(this.fadeInTime, false);
                yield return(new global::UnityEngine.WaitForSeconds(this.fadeInTime));

                bool flag15 = this.front != null;
                if (flag15)
                {
                    global::SteamVR_Skybox.ClearOverride();
                }
            }
        }
        while (this.alpha > 0f)
        {
            yield return(null);
        }
        bool flag16 = overlay != null;

        if (flag16)
        {
            bool flag17 = this.progressBarOverlayHandle > 0UL;
            if (flag17)
            {
                overlay.HideOverlay(this.progressBarOverlayHandle);
            }
            bool flag18 = this.loadingScreenOverlayHandle > 0UL;
            if (flag18)
            {
                overlay.HideOverlay(this.loadingScreenOverlayHandle);
            }
        }
        global::UnityEngine.Object.Destroy(base.gameObject);
        global::SteamVR_LoadLevel._active = null;
        global::SteamVR_Utils.Event.Send("loading", new object[]
        {
            false
        });
        yield break;
    }