void OnPause()
    {
        OVRModeManager.LeaveVRMode();

        RenderTexture.active = null;

        for (int i = 0; i < EyeBufferCount * 2; i++)
        {
            if ((CameraTextures[i] != null) && CameraTextures[i].IsCreated())
            {
                CameraTextures[i].Release();
                CameraTextureIds[i] = 0;
            }
        }
    }
    IEnumerator OnResume()
    {
        yield return(null);                     // delay 1 frame to allow Unity enough time to create the windowSurface

        // When the app is paused and subsequently resumed, we may lose render texture contents.
        // Test for this case and record the new texture id's
        for (int i = 0; i < EyeBufferCount * 2; i++)
        {
            //	DebugUtils.Assert( CameraTextures[i] != null );
            if ((CameraTextures[i] != null) && !CameraTextures[i].IsCreated())
            {
                CameraTextures[i].Create();                 // upload to the GPU so we can get the hardware id
                // Note: calling GetNativeTexturePtr() with mt-rendering will synchronize with the rendering thread,
                // set up texture ids only at initialization time.
                CameraTextureIds[i] = CameraTextures[i].GetNativeTextureID();
            }
        }

        OVRModeManager.EnterVRMode();
    }