Add() public static method

public static Add ( SteamVR_Camera, vrcam ) : void
vrcam SteamVR_Camera,
return void
Beispiel #1
0
    void OnEnable()
    {
        // Bail if no hmd is connected
        var vr = SteamVR.instance;

        if (vr == null)
        {
            if (head != null)
            {
                if (head.GetComponent <SteamVR_TrackedObject>())
                {
                    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);
    }
    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;
        }

        if (blitMaterial == null)
        {
            blitMaterial = new Material(Shader.Find("Custom/SteamVR_Blit"));
        }

        // Ensure rig is properly set up
        Expand();

        // 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.hdr           = camera.hdr;
            headCam.renderingPath = camera.renderingPath;
        }

        SteamVR_Render.Add(this);
    }
Beispiel #3
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(Shader.Find("Custom/SteamVR_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.hdr           = component.hdr;
            component2.renderingPath = component.renderingPath;
        }
        this.ears.GetComponent <SteamVR_Ears>().vrcam = this;
        SteamVR_Render.Add(this);
    }
Beispiel #4
0
    // Token: 0x06000D45 RID: 3397 RVA: 0x000531FC File Offset: 0x000513FC
    private void OnEnable()
    {
        if (SteamVR.instance == null)
        {
            if (this.head != null)
            {
                this.head.GetComponent <SteamVR_TrackedObject>().enabled = false;
            }
            base.enabled = false;
            return;
        }
        Transform transform = base.transform;

        if (this.head != transform)
        {
            this.Expand();
            transform.parent = this.origin;
            while (this.head.childCount > 0)
            {
                this.head.GetChild(0).parent = transform;
            }
            this.head.parent        = transform;
            this.head.localPosition = Vector3.zero;
            this.head.localRotation = Quaternion.identity;
            this.head.localScale    = Vector3.one;
            this.head.gameObject.SetActive(false);
            this._head = transform;
        }
        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);
    }
    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;
        }
#if !(UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
        // 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 (flip != null)
        {
            DestroyImmediate(flip);
            flip = null;
        }
#else
        // Ensure rig is properly set up
        Expand();

        if (blitMaterial == null)
        {
            blitMaterial = new Material(Shader.Find("Custom/SteamVR_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.hdr           = camera.hdr;
            headCam.renderingPath = camera.renderingPath;
        }
#endif
        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);
    }
    void OnEnable()
    {
        try
        {
#if !(UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0 || UNITY_4_5)
            // 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;
                }
                DestroyImmediate(head.gameObject);
                _head = t;
            }

            if (flip != null)
            {
                DestroyImmediate(flip);
                flip = null;
            }

            if (!SteamVR.usingNativeSupport)
            {
                enabled = false;
                return;
            }
#else
            System.Console.WriteLine("OK");
            // 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();
            System.Console.WriteLine("OK2");

            if (blitMaterial == null)
            {
                System.Console.WriteLine("OK3");

                blitMaterial = new Material(UnityHelper.GetShader("SteamVR_Blit"));
                System.Console.WriteLine("OK4" + blitMaterial == null);
            }

            // 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
            System.Console.WriteLine("OK5");

            if (camera.actualRenderingPath != RenderingPath.Forward && QualitySettings.antiAliasing > 1)
            {
                Console.WriteLine("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.hdr           = camera.hdr;
                headCam.renderingPath = camera.renderingPath;
            }
#endif
            System.Console.WriteLine("OK6");

            try
            {
                ears.GetComponent <SteamVR_Ears>().vrcam = this;
            }
            catch (System.Exception e)
            {
                Logger.Info("Ears not found");
            }
            System.Console.WriteLine("OK7");

            SteamVR_Render.Add(this);
            System.Console.WriteLine("OK8");
        } catch (Exception e2)
        {
            Console.WriteLine(e2);
        }
    }
Beispiel #7
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;
            }

            MSCLoader.ModConsole.Print("Failed enabling SteamVR_Camera");
            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 (blitMaterial == null)
        {
            //blitMaterial = new Material(Shader.Find("Custom/SteamVR_Blit"));
            blitMaterial = new Material(@"
Shader ""Custom / SteamVR_Blit"" {

    Properties { _MainTex(""Base (RGB)"", 2D) = ""white"" { }  }


    CGINCLUDE

# include ""UnityCG.cginc""

    sampler2D _MainTex;


    struct v2f {
        float4 pos : SV_POSITION;
		float2 tex : TEXCOORD0;
	};

    v2f vert(appdata_base v) {
        v2f o;
        o.pos = v.vertex;
        o.tex = v.texcoord;
        return o;
    }

    float4 frag(v2f i) : COLOR {
		return tex2D(_MainTex, i.tex);
}

float4 frag_linear(v2f i) : COLOR {
		return pow(tex2D(_MainTex, i.tex), 1.0 / 2.2);
	}

	ENDCG

    SubShader {
    Pass {
        ZTest Always Cull Off ZWrite Off

            Fog { Mode Off }

        CGPROGRAM
#pragma vertex vert
#pragma fragment frag
            ENDCG

        }
    Pass {
        ZTest Always Cull Off ZWrite Off

            Fog { Mode Off }

        CGPROGRAM
#pragma vertex vert
#pragma fragment frag_linear
            ENDCG

        }
}
}
");
        }

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


        // 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)
        {
            MSCLoader.ModConsole.Print("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.hdr           = camera.hdr;
            headCam.renderingPath = camera.renderingPath;
        }

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

        SteamVR_Render.Add(this);
    }
Beispiel #8
0
    void OnEnable()
    {
#if !(UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
        // 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;
            }
            DestroyImmediate(head.gameObject);
            _head = t;
        }

        if (flip != null)
        {
            DestroyImmediate(flip);
            flip = null;
        }

        if (!SteamVR.usingNativeSupport)
        {
            enabled = false;
            return;
        }
#else
        // 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(Shader.Find("Custom/SteamVR_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.hdr           = camera.hdr;
            headCam.renderingPath = camera.renderingPath;
        }
#endif
        ears.GetComponent <SteamVR_Ears>().vrcam = this;
        SteamVR_Render.Add(this);
    }