private void OnDisable()
 {
     SteamVR_Events.InputFocus.Remove(this.OnInputFocus);
     SteamVR_Events.System(EVREventType.VREvent_RequestScreenshot).Remove((this.OnRequestScreenshot));
     UnityHooks.OnBeforeRender -= OnBeforeRender;
     UnityHooks.OnBeforeCull   -= OnCameraPreCull;
     if (SteamVR.initializedState != SteamVR.InitializedStates.InitializeSuccess)
     {
         SteamVR_Events.Initialized.Remove(OnSteamVRInitialized);
     }
 }
        void OnDisable()
        {
            StopAllCoroutines();
            SteamVR_Events.InputFocus.Remove(OnInputFocus);
            SteamVR_Events.System(EVREventType.VREvent_RequestScreenshot).Remove(OnRequestScreenshot);

#if UNITY_2017_1_OR_NEWER
            Application.onBeforeRender -= OnBeforeRender;
#else
            Camera.onPreCull -= OnCameraPreCull;
#endif
        }
Пример #3
0
 private void OnDisable()
 {
     base.StopAllCoroutines();
     SteamVR_Events.InputFocus.Remove(new UnityAction <bool>(this.OnInputFocus));
     SteamVR_Events.System(EVREventType.VREvent_RequestScreenshot).Remove(new UnityAction <VREvent_t>(this.OnRequestScreenshot));
     Application.onBeforeRender -= this.OnBeforeRender;
     Camera.onPreCull            = (Camera.CameraCallback)Delegate.Remove(Camera.onPreCull, new Camera.CameraCallback(this.OnCameraPreCull));
     if (SteamVR.initializedState != SteamVR.InitializedStates.InitializeSuccess)
     {
         SteamVR_Events.Initialized.RemoveListener(new UnityAction <bool>(this.OnSteamVRInitialized));
     }
 }
        void OnEnable()
        {
            StartCoroutine(RenderLoop());
            SteamVR_Events.InputFocus.Listen(OnInputFocus);
            SteamVR_Events.System(EVREventType.VREvent_RequestScreenshot).Listen(OnRequestScreenshot);

#if UNITY_2017_1_OR_NEWER
            Application.onBeforeRender += OnBeforeRender;
#else
            Camera.onPreCull += OnCameraPreCull;
#endif
            var types = new EVRScreenshotType[] { EVRScreenshotType.StereoPanorama };
            OpenVR.Screenshots.HookScreenshot(types);
        }
Пример #5
0
        private void OnDisable()
        {
            StopAllCoroutines();
            SteamVR_Events.InputFocus.Remove(OnInputFocus);
            SteamVR_Events.System(EVREventType.VREvent_RequestScreenshot).Remove(OnRequestScreenshot);

#if UNITY_2017_1_OR_NEWER
            Application.onBeforeRender -= OnBeforeRender;
#else
            Camera.onPreCull -= OnCameraPreCull;
#endif

            if (SteamVR.initializedState != SteamVR.InitializedStates.InitializeSuccess)
            {
                SteamVR_Events.Initialized.RemoveListener(OnSteamVRInitialized);
            }
        }
Пример #6
0
 private void OnEnable()
 {
     base.StartCoroutine(this.RenderLoop());
     SteamVR_Events.InputFocus.Listen(new UnityAction <bool>(this.OnInputFocus));
     SteamVR_Events.System(EVREventType.VREvent_RequestScreenshot).Listen(new UnityAction <VREvent_t>(this.OnRequestScreenshot));
     if (SteamVR_Settings.instance.legacyMixedRealityCamera)
     {
         SteamVR_ExternalCamera_LegacyManager.SubscribeToNewPoses();
     }
     Application.onBeforeRender += this.OnBeforeRender;
     Camera.onPreCull            = (Camera.CameraCallback)Delegate.Combine(Camera.onPreCull, new Camera.CameraCallback(this.OnCameraPreCull));
     if (SteamVR.initializedState == SteamVR.InitializedStates.InitializeSuccess)
     {
         OpenVR.Screenshots.HookScreenshot(this.screenshotTypes);
         return;
     }
     SteamVR_Events.Initialized.AddListener(new UnityAction <bool>(this.OnSteamVRInitialized));
 }
        private void OnEnable()
        {
            MelonCoroutines.Start(RenderLoop());
            SteamVR_Events.InputFocus.Listen((this.OnInputFocus));
            SteamVR_Events.System(EVREventType.VREvent_RequestScreenshot).Listen((this.OnRequestScreenshot));
            if (SteamVR_Settings.instance.legacyMixedRealityCamera)
            {
                SteamVR_ExternalCamera_LegacyManager.SubscribeToNewPoses();
            }

            UnityHooks.OnBeforeRender += OnBeforeRender;
            UnityHooks.OnBeforeCull   += OnCameraPreCull;
            if (SteamVR.initializedState == SteamVR.InitializedStates.InitializeSuccess)
            {
                OpenVR.Screenshots.HookScreenshot(this.screenshotTypes);
                return;
            }
            SteamVR_Events.Initialized.Listen(this.OnSteamVRInitialized);
        }
Пример #8
0
        private void OnEnable()
        {
            StartCoroutine(RenderLoop());
            SteamVR_Events.InputFocus.Listen(OnInputFocus);
            SteamVR_Events.System(EVREventType.VREvent_RequestScreenshot).Listen(OnRequestScreenshot);

#if UNITY_2017_1_OR_NEWER
            Application.onBeforeRender += OnBeforeRender;
#else
            Camera.onPreCull += OnCameraPreCull;
#endif

            if (SteamVR.initializedState == SteamVR.InitializedStates.InitializeSuccess)
            {
                OpenVR.Screenshots.HookScreenshot(screenshotTypes);
            }
            else
            {
                SteamVR_Events.Initialized.AddListener(OnSteamVRInitialized);
            }
        }
Пример #9
0
 protected void OnDisable()
 {
     Application.onBeforeRender -= new UnityAction(this.OnBeforeRender);
     SteamVR_Events.System(EVREventType.VREvent_Quit).Remove(new UnityAction <VREvent_t>(this.OnQuit));
 }
Пример #10
0
 protected void OnDisable()
 {
     UnityHooks.OnBeforeRender -= this.OnBeforeRender;
     SteamVR_Events.System(EVREventType.VREvent_Quit).Remove((this.OnQuit));
 }
 protected void OnDisable()
 {
     Camera.onPreCull -= OnCameraPreCull;
     SteamVR_Events.System(EVREventType.VREvent_Quit).Remove(OnQuit);
 }
 protected void OnDisable()
 {
     Application.onBeforeRender -= OnBeforeRender;
     SteamVR_Events.System(EVREventType.VREvent_Quit).Remove(OnQuit);
 }
Пример #13
0
        private void Update()
        {
            if (!SteamVR.active)
            {
                return;
            }
            this.UpdatePoses();
            CVRSystem system = OpenVR.System;

            if (system != null)
            {
                VREvent_t vrevent_t   = default(VREvent_t);
                uint      uncbVREvent = (uint)Marshal.SizeOf(typeof(VREvent_t));
                int       num         = 0;
                while (num < 64 && system.PollNextEvent(ref vrevent_t, uncbVREvent))
                {
                    EVREventType eventType = (EVREventType)vrevent_t.eventType;
                    if (eventType <= EVREventType.VREvent_InputFocusReleased)
                    {
                        if (eventType != EVREventType.VREvent_InputFocusCaptured)
                        {
                            if (eventType != EVREventType.VREvent_InputFocusReleased)
                            {
                                goto IL_CA;
                            }
                            if (vrevent_t.data.process.pid == 0u)
                            {
                                SteamVR_Events.InputFocus.Send(true);
                            }
                        }
                        else if (vrevent_t.data.process.oldPid == 0u)
                        {
                            SteamVR_Events.InputFocus.Send(false);
                        }
                    }
                    else if (eventType != EVREventType.VREvent_HideRenderModels)
                    {
                        if (eventType != EVREventType.VREvent_ShowRenderModels)
                        {
                            goto IL_CA;
                        }
                        SteamVR_Events.HideRenderModels.Send(false);
                    }
                    else
                    {
                        SteamVR_Events.HideRenderModels.Send(true);
                    }
IL_C4:
                    num++;
                    continue;
IL_CA:
                    SteamVR_Events.System((EVREventType)vrevent_t.eventType).Send(vrevent_t);
                    goto IL_C4;
                }
            }
            Application.targetFrameRate     = -1;
            Application.runInBackground     = true;
            QualitySettings.maxQueuedFrames = -1;
            QualitySettings.vSyncCount      = 0;
            if (SteamVR.settings.lockPhysicsUpdateRateToRenderFrequency && Time.timeScale > 0f)
            {
                SteamVR instance = SteamVR.instance;
                if (instance != null)
                {
                    Time.fixedDeltaTime = Time.timeScale / instance.hmd_DisplayFrequency;
                }
            }
        }
        void Update()
        {
            if (cameras.Length == 0)
            {
                return;
            }
            this.UpdatePoses();
            // If our FixedUpdate rate doesn't match our render framerate, then catch the handoff here.
            SteamVR_Utils.QueueEventOnRenderThread(SteamVR.OpenVRMagic.k_nRenderEventID_PostPresentHandoff);

            // Force controller update in case no one else called this frame to ensure prevState gets updated.

            // Dispatch any OpenVR events.
            var system = OpenVR.System;

            if (system != null)
            {
                var vrEvent = new VREvent_t();
                var size    = (uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(VREvent_t));
                for (int i = 0; i < 64; i++)
                {
                    if (!system.PollNextEvent(ref vrEvent, size))
                    {
                        break;
                    }

                    switch ((EVREventType)vrEvent.eventType)
                    {
                    case EVREventType.VREvent_InputFocusCaptured:     // another app has taken focus (likely dashboard)
                        if (vrEvent.data.process.oldPid == 0)
                        {
                            SteamVR_Events.InputFocus.Send(false);
                        }
                        break;

                    case EVREventType.VREvent_InputFocusReleased:     // that app has released input focus
                        if (vrEvent.data.process.pid == 0)
                        {
                            SteamVR_Events.InputFocus.Send(true);
                        }
                        break;

                    case EVREventType.VREvent_ShowRenderModels:
                        SteamVR_Events.HideRenderModels.Send(false);
                        break;

                    case EVREventType.VREvent_HideRenderModels:
                        SteamVR_Events.HideRenderModels.Send(true);
                        break;

                    default:
                        SteamVR_Events.System((EVREventType)vrEvent.eventType).Send(vrEvent);
                        break;
                    }
                }
            }

            // Ensure various settings to minimize latency.
            Application.targetFrameRate     = -1;
            Application.runInBackground     = true; // don't require companion window focus
            QualitySettings.maxQueuedFrames = -1;
            QualitySettings.vSyncCount      = 0;    // this applies to the companion window
        }
Пример #15
0
        void Update()
        {
            if (SteamVR.active == false)
            {
                return;
            }

            UpdatePoses();

            // Dispatch any OpenVR events.
            var system = OpenVR.System;

            if (system != null)
            {
                var vrEvent = new VREvent_t();
                var size    = (uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(VREvent_t));
                for (int i = 0; i < 64; i++)
                {
                    if (!system.PollNextEvent(ref vrEvent, size))
                    {
                        break;
                    }

                    switch ((EVREventType)vrEvent.eventType)
                    {
                    case EVREventType.VREvent_InputFocusCaptured:     // another app has taken focus (likely dashboard)
                        if (vrEvent.data.process.oldPid == 0)
                        {
                            SteamVR_Events.InputFocus.Send(false);
                        }

                        break;

                    case EVREventType.VREvent_InputFocusReleased:     // that app has released input focus
                        if (vrEvent.data.process.pid == 0)
                        {
                            SteamVR_Events.InputFocus.Send(true);
                        }

                        break;

                    case EVREventType.VREvent_ShowRenderModels:
                        SteamVR_Events.HideRenderModels.Send(false);
                        break;

                    case EVREventType.VREvent_HideRenderModels:
                        SteamVR_Events.HideRenderModels.Send(true);
                        break;

                    default:
                        SteamVR_Events.System((EVREventType)vrEvent.eventType).Send(vrEvent);
                        break;
                    }
                }
            }

            // Ensure various settings to minimize latency.
            Application.targetFrameRate     = -1;
            Application.runInBackground     = true; // don't require companion window focus
            QualitySettings.maxQueuedFrames = -1;
            QualitySettings.vSyncCount      = 0;    // this applies to the companion window

            if (SteamVR.settings.lockPhysicsUpdateRateToRenderFrequency && Time.timeScale > 0.0f)
            {
                var vr = SteamVR.instance;
                if (vr != null)
                {
                    var timing = new Compositor_FrameTiming();
                    timing.m_nSize =
                        (uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(Compositor_FrameTiming));
                    vr.compositor.GetFrameTiming(ref timing, 0);

                    Time.fixedDeltaTime = Time.timeScale / vr.hmd_DisplayFrequency;
                }
            }
        }
 protected void OnEnable()
 {
     Application.onBeforeRender += OnBeforeRender;
     SteamVR_Events.System(EVREventType.VREvent_Quit).Listen(OnQuit);
 }
Пример #17
0
 SteamVR_TrackedObject()
 {
     newPosesAction = SteamVR_Events.NewPosesAction(OnNewPoses);
 }
 protected void OnEnable()
 {
     Camera.onPreCull += OnCameraPreCull;
     SteamVR_Events.System(EVREventType.VREvent_Quit).Listen(OnQuit);
 }
 private void Awake()
 {
     newPosesAction = SteamVR_Events.NewPosesAction(OnNewPoses);
     OnEnable();
 }
Пример #20
0
 SteamVR_RenderModel()
 {
     deviceConnectedAction              = SteamVR_Events.DeviceConnectedAction(OnDeviceConnected);
     hideRenderModelsAction             = SteamVR_Events.HideRenderModelsAction(OnHideRenderModels);
     modelSkinSettingsHaveChangedAction = SteamVR_Events.SystemAction(EVREventType.VREvent_ModelSkinSettingsHaveChanged, OnModelSkinSettingsHaveChanged);
 }
Пример #21
0
 protected void OnEnable()
 {
     UnityHooks.OnBeforeRender += this.OnBeforeRender;
     SteamVR_Events.System(EVREventType.VREvent_Quit).Listen((this.OnQuit));
 }