Exemplo n.º 1
0
        void OnEnable()
        {
            // Bail if no hmd is connected

            var vr = SteamVR.instance;

            if (vr == null)
            {
                if (head != null)
                {
                    head.GetComponent <SteamVR_TrackedObject>().enabled = false;
                }

                enabled = false;
                return;
            }

            // Convert camera rig for native OpenVR integration.
            var t = transform;

            if (head != t)
            {
                Expand();

                t.parent = origin;

                while (head.childCount > 0)
                {
                    head.GetChild(0).parent = t;
                }

                // Keep the head around, but parent to the camera now since it moves with the hmd
                // but existing content may still have references to this object.
                head.parent        = t;
                head.localPosition = Vector3.zero;
                head.localRotation = Quaternion.identity;
                head.localScale    = Vector3.one;
                head.gameObject.SetActive(false);

                _head = t;
            }

            if (ears == null)
            {
                var e = transform.GetComponentInChildren <SteamVR_Ears>();
                if (e != null)
                {
                    _ears = e.transform;
                }
            }

            if (ears != null)
            {
                ears.GetComponent <SteamVR_Ears>().vrcam = this;
            }

            SteamVR_Render.Add(this);
        }
Exemplo n.º 2
0
        private void OnEnable()
        {
            SteamVR instance = SteamVR.instance;

            if (instance == null)
            {
                if (this.head != null)
                {
                    this.head.GetComponent <SteamVR_GameView>().enabled      = false;
                    this.head.GetComponent <SteamVR_TrackedObject>().enabled = false;
                }
                if (this.flip != null)
                {
                    this.flip.enabled = false;
                }
                base.enabled = false;
                return;
            }
            this.Expand();
            if (SteamVR_Camera.blitMaterial == null)
            {
                SteamVR_Camera.blitMaterial = new Material(VRShaders.GetShader(VRShaders.VRShader.blit));
            }
            Camera component = base.GetComponent <Camera>();

            component.fieldOfView  = instance.fieldOfView;
            component.aspect       = instance.aspect;
            component.eventMask    = 0;
            component.orthographic = false;
            component.enabled      = false;
            if (component.actualRenderingPath != RenderingPath.Forward && QualitySettings.antiAliasing > 1)
            {
                Debug.LogWarning("MSAA only supported in Forward rendering path. (disabling MSAA)");
                QualitySettings.antiAliasing = 0;
            }
            Camera component2 = this.head.GetComponent <Camera>();

            if (component2 != null)
            {
                component2.renderingPath = component.renderingPath;
            }
            if (this.ears == null)
            {
                SteamVR_Ears componentInChildren = base.transform.GetComponentInChildren <SteamVR_Ears>();
                if (componentInChildren != null)
                {
                    this._ears = componentInChildren.transform;
                }
            }
            if (this.ears != null)
            {
                this.ears.GetComponent <SteamVR_Ears>().vrcam = this;
            }
            SteamVR_Render.Add(this);
        }
Exemplo n.º 3
0
        void OnEnable()
        {
            // Bail if no hmd is connected
            var vr = SteamVR.instance;

            if (vr == null)
            {
                if (head != null)
                {
                    head.GetComponent <SteamVR_GameView>().enabled      = false;
                    head.GetComponent <SteamVR_TrackedObject>().enabled = false;
                }

                if (flip != null)
                {
                    flip.enabled = false;
                }

                enabled = false;
                return;
            }
            // Ensure rig is properly set up
            Expand();

            if (blitMaterial == null)
            {
                blitMaterial = new Material(VRShaders.GetShader(VRShaders.VRShader.blit));
            }

            // Set remaining hmd specific settings
            var camera = GetComponent <Camera>();

            camera.fieldOfView  = vr.fieldOfView;
            camera.aspect       = vr.aspect;
            camera.eventMask    = 0;     // disable mouse events
            camera.orthographic = false; // force perspective
            camera.enabled      = false; // manually rendered by SteamVR_Render

            if (camera.actualRenderingPath != RenderingPath.Forward && QualitySettings.antiAliasing > 1)
            {
                Debug.LogWarning("MSAA only supported in Forward rendering path. (disabling MSAA)");
                QualitySettings.antiAliasing = 0;
            }

            // Ensure game view camera hdr setting matches
            var headCam = head.GetComponent <Camera>();

            if (headCam != null)
            {
                headCam.renderingPath = camera.renderingPath;
            }

            if (ears == null)
            {
                var e = transform.GetComponentInChildren <SteamVR_Ears>();
                if (e != null)
                {
                    _ears = e.transform;
                }
            }

            if (ears != null)
            {
                ears.GetComponent <SteamVR_Ears>().vrcam = this;
            }

            SteamVR_Render.Add(this);
        }