Inheritance: MonoBehaviour
Example #1
0
 public static void Remove(SteamVR_Camera vrcam)
 {
     if (!isQuitting && _instance != null)
     {
         instance.RemoveInternal(vrcam);
     }
 }
    public void AttachToCamera(SteamVR_Camera vrcam)
    {
        if (target == vrcam.head)
            return;

        target = vrcam.head;

        var root = transform.parent;
        var origin = vrcam.head.parent;
        root.parent = origin;
        root.localPosition = Vector3.zero;
        root.localRotation = Quaternion.identity;
        root.localScale = Vector3.one;

        // Make a copy of the eye camera to pick up any camera fx.
        vrcam.enabled = false;
        var go = Instantiate(vrcam.gameObject);
        vrcam.enabled = true;
        go.name = "camera";

        DestroyImmediate(go.GetComponent<SteamVR_Camera>());

        cam = go.GetComponent<Camera>();
        cam.fieldOfView = config.fov;
        cam.useOcclusionCulling = false;
        cam.enabled = false; // manually rendered

        colorMat = new Material(Shader.Find("Custom/SteamVR_ColorOut"));
        alphaMat = new Material(Shader.Find("Custom/SteamVR_AlphaOut"));
        clipMaterial = new Material(Shader.Find("Custom/SteamVR_ClearAll"));

        var offset = go.transform;
        offset.parent = transform;
        offset.localPosition = new Vector3(config.x, config.y, config.z);
        offset.localRotation = Quaternion.Euler(config.rx, config.ry, config.rz);
        offset.localScale = Vector3.one;

        // Strip children of cloned object (AudioListener in particular).
        while (offset.childCount > 0)
            DestroyImmediate(offset.GetChild(0).gameObject);

        // Setup clipping quad (using camera clip causes problems with shadows).
        clipQuad = GameObject.CreatePrimitive(PrimitiveType.Quad);
        clipQuad.name = "ClipQuad";
        DestroyImmediate(clipQuad.GetComponent<MeshCollider>());

        var clipRenderer = clipQuad.GetComponent<MeshRenderer>();
        clipRenderer.material = clipMaterial;
        clipRenderer.shadowCastingMode = ShadowCastingMode.Off;
        clipRenderer.receiveShadows = false;
        clipRenderer.lightProbeUsage = LightProbeUsage.Off;
        clipRenderer.reflectionProbeUsage = ReflectionProbeUsage.Off;

        var clipTransform = clipQuad.transform;
        clipTransform.parent = offset;
        clipTransform.localScale = new Vector3(1000.0f, 1000.0f, 1.0f);
        clipTransform.localRotation = Quaternion.identity;

        clipQuad.SetActive(false);
    }
Example #3
0
 public static void Add(SteamVR_Camera vrcam)
 {
     if (!isQuitting)
     {
         instance.AddInternal(vrcam);
     }
 }
Example #4
0
    // Use this for initialization
    void Start()
    {
        poseArray = new TrackedDevicePose_t[OpenVR.k_unMaxTrackedDeviceCount];
        SteamVR_Events.DeviceConnected.Listen(OnDeviceConnected);
        SteamVR_Events.System(EVREventType.VREvent_ChaperoneUniverseHasChanged).Listen(OnUniverseChanged);
        SteamVR_Events.InputFocus.Listen(OnInputFocus);
        SteamVR_Events.NewPoses.Listen(OnNewPoses);
        baseStations = new List <string> ();

        if (hmdTracking)
        {
            GetChaperoneSize();
        }

        currGameAreaPos = player.transform.position;
        //	backupCamera = GameObject.FindGameObjectWithTag ("BackupCamera");


        backupCamera.gameObject.SetActive(false);
        mainCam   = headCamera.GetComponent <SteamVR_Camera> ();
        backupCam = backupCamera.GetComponent <SteamVR_Camera> ();
        tracker   = GameObject.Find("Tracker");

        height = Random.Range(0.8f, 1.6f);
        initialPlayerPosition      = player.transform.position;
        initialEnvironmentPosition = GameObject.Find("Environment").transform.position;
    }
        public override void Initialize(NVRPlayer player)
        {
            Player = player;
            Player.gameObject.SetActive(false);

            SteamVR_ControllerManager controllerManager = Player.gameObject.AddComponent <SteamVR_ControllerManager>();

            controllerManager.left  = Player.LeftHand.gameObject;
            controllerManager.right = Player.RightHand.gameObject;

            //Player.gameObject.AddComponent<SteamVR_PlayArea>();

            for (int index = 0; index < Player.Hands.Length; index++)
            {
                Player.Hands[index].gameObject.AddComponent <SteamVR_TrackedObject>();
            }


            SteamVR_Camera steamVrCamera = Player.Head.gameObject.AddComponent <SteamVR_Camera>();

            Player.Head.gameObject.AddComponent <SteamVR_Ears>();
            NVRHelpers.SetField(steamVrCamera, "_head", Player.Head.transform, false);
            NVRHelpers.SetField(steamVrCamera, "_ears", Player.Head.transform, false);

            Player.Head.gameObject.AddComponent <SteamVR_TrackedObject>();

            Player.gameObject.SetActive(true);

            SteamVR_Render[] steamvr_objects = GameObject.FindObjectsOfType <SteamVR_Render>();
            for (int objectIndex = 0; objectIndex < steamvr_objects.Length; objectIndex++)
            {
                steamvr_objects[objectIndex].lockPhysicsUpdateRateToRenderFrequency = false; //this generally seems to break things :) Just make sure your Time -> Physics Timestep is set to 0.011
            }
        }
    void AddInternal(SteamVR_Camera vrcam)
    {
        var camera = vrcam.GetComponent <Camera>();
        var length = cameras.Length;
        var sorted = new SteamVR_Camera[length + 1];
        int insert = 0;

        for (int i = 0; i < length; i++)
        {
            var c = cameras[i].GetComponent <Camera>();
            if (i == insert && c.depth > camera.depth)
            {
                sorted[insert++] = vrcam;
            }

            sorted[insert++] = cameras[i];
        }
        if (insert == length)
        {
            sorted[insert] = vrcam;
        }

        cameras = sorted;

#if (UNITY_5_3_OR_NEWER || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
        enabled = true;
#endif
    }
Example #7
0
        void Awake()
        {
            SteamVR_Camera steamCamera = this.transform.parent.gameObject.GetComponentInChildren <SteamVR_Camera>();

            if (steamCamera == null)
            {
                vrCamera = Camera.main.transform;
            }
            else
            {
                vrCamera = steamCamera.transform;
            }
            if (vrCamera == null)
            {
                Debug.LogError("vrCamera is null");
                enabled = false;
                return;
            }
            SteamVR_PlayArea steamPlayArea = this.transform.parent.gameObject.GetComponent <SteamVR_PlayArea>();

            if (steamPlayArea == null)
            {
                vrPlayArea = transform.parent;
            }
            else
            {
                vrPlayArea = steamPlayArea.transform;
            }
            if (vrPlayArea == null)
            {
                Debug.LogError("vrplayarea is null");
                enabled = false;
                return;
            }
        }
Example #8
0
    // Token: 0x06005F56 RID: 24406 RVA: 0x00217BE4 File Offset: 0x00215FE4
    private void RemoveInternal(SteamVR_Camera vrcam)
    {
        int num  = this.cameras.Length;
        int num2 = 0;

        for (int i = 0; i < num; i++)
        {
            SteamVR_Camera x = this.cameras[i];
            if (x == vrcam)
            {
                num2++;
            }
        }
        if (num2 == 0)
        {
            return;
        }
        SteamVR_Camera[] array = new SteamVR_Camera[num - num2];
        int num3 = 0;

        for (int j = 0; j < num; j++)
        {
            SteamVR_Camera steamVR_Camera = this.cameras[j];
            if (steamVR_Camera != vrcam)
            {
                array[num3++] = steamVR_Camera;
            }
        }
        this.cameras = array;
    }
        public override void Initialize(NVRPlayer player)
        {
            Player = player;
            Player.gameObject.SetActive(false);

            SteamVR_ControllerManager controllerManager = Player.gameObject.AddComponent <SteamVR_ControllerManager>();

            controllerManager.left  = Player.LeftHand.gameObject;
            controllerManager.right = Player.RightHand.gameObject;
            //controllerManager.objects = new GameObject[2] { Player.LeftHand.gameObject, Player.RightHand.gameObject };

            Player.gameObject.AddComponent <SteamVR_PlayArea>();

            for (int index = 0; index < Player.Hands.Length; index++)
            {
                Player.Hands[index].gameObject.AddComponent <SteamVR_TrackedObject>();
            }


            SteamVR_Camera steamVrCamera = Player.Head.gameObject.AddComponent <SteamVR_Camera>();
            SteamVR_Ears   steamVrEars   = Player.Head.gameObject.AddComponent <SteamVR_Ears>();

            NVRHelpers.SetField(steamVrCamera, "_head", Player.Head.transform, false);
            NVRHelpers.SetField(steamVrCamera, "_ears", Player.Head.transform, false);

            Player.Head.gameObject.AddComponent <SteamVR_TrackedObject>();

            Player.gameObject.SetActive(true);
        }
Example #10
0
 // Token: 0x06005F53 RID: 24403 RVA: 0x00217B10 File Offset: 0x00215F10
 public static void Remove(SteamVR_Camera vrcam)
 {
     if (!SteamVR_Render.isQuitting && SteamVR_Render._instance != null)
     {
         SteamVR_Render.instance.RemoveInternal(vrcam);
     }
 }
Example #11
0
    void RenderEye(SteamVR vr, Hmd_Eye eye, LayerMask mask)
    {
        int i = (int)eye;

        SteamVR_Render.eye = eye;

        if (cameraMask != null)
        {
            cameraMask.Set(vr, eye);
        }

        foreach (var c in cameras)
        {
            c.transform.localPosition = vr.eyes[i].pos;
            c.transform.localRotation = vr.eyes[i].rot;

            // Update position to keep from getting culled
            cameraMask.transform.position = c.transform.position;

            var camera = c.GetComponent <Camera>();
            camera.targetTexture = SteamVR_Camera.GetSceneTexture(camera.hdr);
            int cullingMask = camera.cullingMask;
            camera.cullingMask |= mask;
            camera.Render();
            camera.cullingMask = cullingMask;
        }
    }
Example #12
0
    // Use this for initialization
    void Start()
    {
        cameraScript    = cameraRig.transform.Find("Camera (eye)").GetComponent <SteamVR_Camera>();
        watchAnimator   = canvasSet.GetComponent <Animator>();
        selfCollider    = GetComponent <SphereCollider>();
        canvasColliders = new List <Collider>();
        foreach (Transform t in canvasSet.transform)
        {
            canvasColliders.Add(t.gameObject.GetComponent <BoxCollider>());
        }
        notificationCanvasOn = false;
        timeCanvas.SetActive(true);
        canvasSet.SetActive(false);
        trackedObj = leftController.GetComponent <SteamVR_TrackedObject>();

        noticed    = false;
        interacted = false;
        ended      = false;


        // disable notification canavases by default
        // enable time canvas, which shows time  by default
        // wait for keyboard trigger to enable notification canvases and disable time canvas
        // once reading is done, back to time canvas.
        //
    }
Example #13
0
    private IEnumerator RenderLoop()
    {
        while (true)
        {
            yield return(new WaitForEndOfFrame());

            var vr = SteamVR.instance;

            if (vr.compositor.CanRenderScene())
            {
                vr.compositor.SetTrackingSpace(trackingSpace);
                vr.compositor.WaitGetPoses(poses, gamePoses);
                SteamVR_Utils.Event.Send("new_poses", poses);
            }

            GL.IssuePluginEvent(20150313);                                                                // Fire off render event to perform our compositor sync
            SteamVR_Camera.GetSceneTexture(cameras[0].GetComponent <Camera>().hdr).GetNativeTexturePtr(); // flush render event

            var overlay = SteamVR_Overlay.instance;
            if (overlay != null)
            {
                overlay.UpdateOverlay(vr);
            }

            RenderEye(vr, Hmd_Eye.Eye_Left, leftMask);
            RenderEye(vr, Hmd_Eye.Eye_Right, rightMask);

            if (cameraMask != null)
            {
                cameraMask.Clear();
            }

            GL.IssuePluginEvent(20150213);             // Fire off render event for in-process present hook
        }
    }
Example #14
0
    void AddInternal(SteamVR_Camera vrcam)
    {
        try
        {
            var camera = vrcam.GetComponent <Camera>();
            var length = cameras.Length;
            var sorted = new SteamVR_Camera[length + 1];
            int insert = 0;
            for (int i = 0; i < length; i++)
            {
                var c = cameras[i].GetComponent <Camera>();
                if (i == insert && c.depth > camera.depth)
                {
                    sorted[insert++] = vrcam;
                }

                sorted[insert++] = cameras[i];
            }
            if (insert == length)
            {
                sorted[insert] = vrcam;
            }

            cameras = sorted;
        } catch (Exception e)
        {
            Console.WriteLine(e);
        }
    }
Example #15
0
    private void RemoveInternal(SteamVR_Camera vrcam)
    {
        var length = cameras.Length;
        int count  = 0;

        for (int i = 0; i < length; i++)
        {
            var c = cameras[i];
            if (c == vrcam)
            {
                ++count;
            }
        }
        if (count == 0)
        {
            return;
        }

        var sorted = new SteamVR_Camera[length - count];
        int insert = 0;

        for (int i = 0; i < length; i++)
        {
            var c = cameras[i];
            if (c != vrcam)
            {
                sorted[insert++] = c;
            }
        }

        cameras = sorted;
    }
Example #16
0
    private IEnumerator RenderLoop()
    {
        while (Application.isPlaying)
        {
            yield return(waitForEndOfFrame);

            if (pauseRendering)
            {
                continue;
            }

            var compositor = OpenVR.Compositor;
            if (compositor != null)
            {
                if (!compositor.CanRenderScene())
                {
                    continue;
                }

                compositor.SetTrackingSpace(trackingSpace);



                //SteamVR_Utils.QueueEventOnRenderThread(SteamVR.Unity.k_nRenderEventID_WaitGetPoses);
                //This is what the above commented out line does:
                GL.IssuePluginEvent(201510020);

                // Hack to flush render event that was queued in Update (this ensures WaitGetPoses has returned before we grab the new values).
                SteamVR_Camera.GetSceneTexture(cameras[0].GetComponent <Camera>().hdr).GetNativeTexturePtr();

                compositor.GetLastPoses(poses, gamePoses);

                SteamVR_Events.NewPoses.Send(poses);
                SteamVR_Events.NewPosesApplied.Send();
            }

            var overlay = SteamVR_Overlay.instance;
            if (overlay != null)
            {
                overlay.UpdateOverlay();
            }

            var vr = SteamVR.instance;
            RenderEye(vr, EVREye.Eye_Left);
            RenderEye(vr, EVREye.Eye_Right);

            // Move cameras back to head position so they can be tracked reliably
            foreach (var c in cameras)
            {
                c.transform.localPosition = Vector3.zero;
                c.transform.localRotation = Quaternion.identity;
            }

            if (cameraMask != null)
            {
                cameraMask.Clear();
            }
        }
    }
Example #17
0
        public override void SetVREnabled(bool isEnabled)
        {
            if (!IsPresent)
            {
                return;
            }

            if (steamCamera == null)
            {
                var playerObject  = GameObject.FindWithTag("Player");
                var camera        = Camera.main.transform;
                var trackingSpace = camera.parent;
                var head          = trackingSpace != null ? trackingSpace.parent : trackingSpace;

                if (playerObject == null || trackingSpace == null)
                {
                    throw new UnityException("[OpenVRManager] Your prefab doesn't respect the correct hierarchy");
                }

                // Creates the SteamVR's main camera.
                steamCamera = camera.gameObject.AddComponent <SteamVR_Camera>();

                // The controllers.
                if (_addControllersNode)
                {
                    var controllerGameObject = new GameObject("SteamVR_Controllers");
                    var controllerTransform  = controllerGameObject.transform;
                    controllerTransform.parent        = head;
                    controllerTransform.localPosition = Vector3.zero;
                    controllerTransform.localRotation = Quaternion.identity;
                    // We need to disable the gameobject because the SteamVR_ControllerManager component
                    // Will check attached controllers in the awake method.
                    // Here we don't have attached controllers yet.
                    controllerGameObject.SetActive(false);

                    var controllerManager = controllerGameObject.AddComponent <SteamVR_ControllerManager>();
                    controllerManager.left  = CreateController(controllerManager.transform, "Controller (left)");
                    controllerManager.right = CreateController(controllerManager.transform, "Controller (right)");

                    // Now that controllers are attached, we can enable the GameObject
                    controllerGameObject.SetActive(true);
                }

                // And finally the play area.
                if (_addPlayArea)
                {
                    var playArea = new GameObject("SteamVR_PlayArea");
                    playArea.transform.parent = playerObject.transform;
                    playArea.AddComponent <MeshRenderer>();
                    playArea.AddComponent <MeshFilter>();
                    playArea.AddComponent <SteamVR_PlayArea>();
                }

                head.localPosition = Vector3.zero;
                head.localRotation = Quaternion.identity;
            }

            VRSettings.enabled = isEnabled;
        }
        private static void Prefix(ref Resolution res)
        {
            // We use the unscaled resolution for screen liquid effects to prevent the effects from being scaled or going off-screen
            Resolution scaledHMDRes = SteamVR_Camera.GetResolutionForAspect(16, 9);

            res.width  = scaledHMDRes.width;
            res.height = scaledHMDRes.height;
        }
Example #19
0
    private void GetReferencesSteamVR()
    {
        var scm = GetComponentInChildren <SteamVR_ControllerManager>(true);

        steamVRRoot  = scm.gameObject;
        steamVrHead  = GetComponentInChildren <SteamVR_Camera>(true);
        steamVrLeft  = scm.left;
        steamVrRight = scm.right;
    }
Example #20
0
    void OnPostRender()
    {
        var vr     = SteamVR.instance;
        var camera = GetComponent <Camera>();
        var aspect = scale * camera.aspect / vr.aspect;

        var x0 = -scale;
        var x1 = scale;
        var y0 = aspect;
        var y1 = -aspect;

        var blitMaterial = SteamVR_Camera.blitMaterial;

        blitMaterial.mainTexture = SteamVR_Camera.GetSceneTexture(camera.hdr);

        GL.PushMatrix();
        GL.LoadOrtho();
#if !(UNITY_5_0)
        blitMaterial.SetPass(0);
#else
        blitMaterial.SetPass(QualitySettings.activeColorSpace == ColorSpace.Linear ? 1 : 0);
#endif
        GL.Begin(GL.QUADS);
        GL.TexCoord2(0.0f, 0.0f); GL.Vertex3(x0, y0, 0);
        GL.TexCoord2(1.0f, 0.0f); GL.Vertex3(x1, y0, 0);
        GL.TexCoord2(1.0f, 1.0f); GL.Vertex3(x1, y1, 0);
        GL.TexCoord2(0.0f, 1.0f); GL.Vertex3(x0, y1, 0);
        GL.End();
        GL.PopMatrix();

        var overlay = SteamVR_Overlay.instance;
        if (overlay && overlay.texture && overlayMaterial && drawOverlay)
        {
            var texture = overlay.texture;
            overlayMaterial.mainTexture = texture;

            var u0 = 0.0f;
            var v0 = 1.0f - (float)Screen.height / texture.height;
            var u1 = (float)Screen.width / texture.width;
            var v1 = 1.0f;

            GL.PushMatrix();
            GL.LoadOrtho();
#if !(UNITY_5_0)
            overlayMaterial.SetPass(QualitySettings.activeColorSpace == ColorSpace.Linear ? 1 : 0);
#else
            overlayMaterial.SetPass(0);
#endif
            GL.Begin(GL.QUADS);
            GL.TexCoord2(u0, v0); GL.Vertex3(-1, -1, 0);
            GL.TexCoord2(u1, v0); GL.Vertex3(1, -1, 0);
            GL.TexCoord2(u1, v1); GL.Vertex3(1, 1, 0);
            GL.TexCoord2(u0, v1); GL.Vertex3(-1, 1, 0);
            GL.End();
            GL.PopMatrix();
        }
    }
Example #21
0
    // Token: 0x06000D79 RID: 3449 RVA: 0x00054530 File Offset: 0x00052730
    public void AttachToCamera(SteamVR_Camera vrcam)
    {
        if (this.target == vrcam.head)
        {
            return;
        }
        this.target = vrcam.head;
        Transform parent  = base.transform.parent;
        Transform parent2 = vrcam.head.parent;

        parent.parent        = parent2;
        parent.localPosition = Vector3.zero;
        parent.localRotation = Quaternion.identity;
        parent.localScale    = Vector3.one;
        vrcam.enabled        = false;
        GameObject gameObject = Object.Instantiate <GameObject>(vrcam.gameObject);

        vrcam.enabled   = true;
        gameObject.name = "camera";
        Object.DestroyImmediate(gameObject.GetComponent <SteamVR_Camera>());
        Object.DestroyImmediate(gameObject.GetComponent <SteamVR_Fade>());
        this.cam = gameObject.GetComponent <Camera>();
        this.cam.stereoTargetEye     = StereoTargetEyeMask.None;
        this.cam.fieldOfView         = this.config.fov;
        this.cam.useOcclusionCulling = false;
        this.cam.enabled             = false;
        this.colorMat     = new Material(Shader.Find("Custom/SteamVR_ColorOut"));
        this.alphaMat     = new Material(Shader.Find("Custom/SteamVR_AlphaOut"));
        this.clipMaterial = new Material(Shader.Find("Custom/SteamVR_ClearAll"));
        Transform transform = gameObject.transform;

        transform.parent        = base.transform;
        transform.localPosition = new Vector3(this.config.x, this.config.y, this.config.z);
        transform.localRotation = Quaternion.Euler(this.config.rx, this.config.ry, this.config.rz);
        transform.localScale    = Vector3.one;
        while (transform.childCount > 0)
        {
            Object.DestroyImmediate(transform.GetChild(0).gameObject);
        }
        this.clipQuad      = GameObject.CreatePrimitive(PrimitiveType.Quad);
        this.clipQuad.name = "ClipQuad";
        Object.DestroyImmediate(this.clipQuad.GetComponent <MeshCollider>());
        MeshRenderer component = this.clipQuad.GetComponent <MeshRenderer>();

        component.material             = this.clipMaterial;
        component.shadowCastingMode    = ShadowCastingMode.Off;
        component.receiveShadows       = false;
        component.lightProbeUsage      = LightProbeUsage.Off;
        component.reflectionProbeUsage = ReflectionProbeUsage.Off;
        Transform transform2 = this.clipQuad.transform;

        transform2.parent        = transform;
        transform2.localScale    = new Vector3(1000f, 1000f, 1f);
        transform2.localRotation = Quaternion.identity;
        this.clipQuad.SetActive(false);
    }
Example #22
0
    public void Awake()
    {
        playerCtrl = GetComponent <PlayerController>();
        headCamera = GetComponentInChildren <SteamVR_Camera>();

        if (!playerCtrl.IsViveController)
        {
            throw new System.Exception("Cannot use VivePlayerMovement on non vive player");
        }
    }
Example #23
0
    private void SetScale(float scale)
    {
        this.scale = scale;
        SteamVR_Camera steamVR_Camera = SteamVR_Render.Top();

        if (steamVR_Camera != null)
        {
            steamVR_Camera.origin.localScale = new Vector3(scale, scale, scale);
        }
    }
Example #24
0
    void setPositionalData(SensorData sensor, SteamVR_Camera head)
    {
        sensor.position.x = head.transform.position.x;
        sensor.position.y = head.transform.position.y;
        sensor.position.z = head.transform.position.z;

        sensor.rotation.pitch = head.transform.rotation.eulerAngles.y;
        sensor.rotation.yaw   = head.transform.rotation.eulerAngles.z;
        sensor.rotation.roll  = head.transform.rotation.eulerAngles.x;
    }
Example #25
0
 private void SetupVRPlayerCamera()
 {
     if (VRCamera)
     {
         return;
     }
     // Handle head transform manually to better fit into the game's systems and allow things like syncing lookDir online
     // This is handled in harmony injections to FPSCamera
     VRCamera = fpscamera.gameObject.AddComponent <SteamVR_Camera>();
 }
Example #26
0
 void FindTracker()
 {
     foreach (var cam in Object.FindObjectsOfType(typeof(SteamVR_Camera)) as SteamVR_Camera[])
     {
         if (cam.applyDistortion)
         {
             tracker = cam;
             break;
         }
     }
 }
Example #27
0
 public void ForceLast()
 {
     if (SteamVR_Camera.values != null)
     {
         IDictionaryEnumerator enumerator = SteamVR_Camera.values.GetEnumerator();
         try
         {
             while (enumerator.MoveNext())
             {
                 object          obj             = enumerator.Current;
                 DictionaryEntry dictionaryEntry = (DictionaryEntry)obj;
                 FieldInfo       fieldInfo       = dictionaryEntry.Key as FieldInfo;
                 fieldInfo.SetValue(this, dictionaryEntry.Value);
             }
         }
         finally
         {
             IDisposable disposable;
             if ((disposable = (enumerator as IDisposable)) != null)
             {
                 disposable.Dispose();
             }
         }
         SteamVR_Camera.values = null;
     }
     else
     {
         Component[] components = base.GetComponents <Component>();
         for (int i = 0; i < components.Length; i++)
         {
             SteamVR_Camera steamVR_Camera = components[i] as SteamVR_Camera;
             if (steamVR_Camera != null && steamVR_Camera != this)
             {
                 UnityEngine.Object.DestroyImmediate(steamVR_Camera);
             }
         }
         components = base.GetComponents <Component>();
         if (this != components[components.Length - 1])
         {
             SteamVR_Camera.values = new Hashtable();
             FieldInfo[] fields = base.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
             foreach (FieldInfo fieldInfo2 in fields)
             {
                 if (fieldInfo2.IsPublic || fieldInfo2.IsDefined(typeof(SerializeField), true))
                 {
                     SteamVR_Camera.values[fieldInfo2] = fieldInfo2.GetValue(this);
                 }
             }
             GameObject gameObject = base.gameObject;
             UnityEngine.Object.DestroyImmediate(this);
             gameObject.AddComponent <SteamVR_Camera>().ForceLast();
         }
     }
 }
Example #28
0
    // Start is called before the first frame update
    void Start()
    {
        head      = SteamVR_Render.Top().head;
        rb        = GetComponent <Rigidbody>();
        player    = GetComponent <CapsuleCollider>();
        vision    = GetComponent <SteamVR_Camera>();
        LeftHand  = GetComponentInChildren <Transform>();
        RightHand = GetComponentInChildren <Transform>();

        velocity.y = Mathf.Clamp(velocity.y, 0, 100);
    }
Example #29
0
    // Token: 0x060055B2 RID: 21938 RVA: 0x001D894C File Offset: 0x001D6D4C
    public override void Awake()
    {
        base.Awake();
        this.mouseGaze     = base.GetComponentInChildren <NeckMouseRotator>();
        this.neckTransform = this.mouseGaze.transform;
        this.gameView      = base.GetComponentInChildren <SteamVR_GameView>();
        this.eyeTransform  = this.neckTransform.GetChild(0);
        this.postCamera    = this.gameView.GetComponent <Camera>();
        SteamVR_Camera componentInChildren = base.GetComponentInChildren <SteamVR_Camera>();

        this.eyeCamera = componentInChildren.GetComponent <Camera>();
    }
Example #30
0
 private void StationSensor(Collider other, VRSensor sensor)
 {
     if (!trainDepart)
     {
         SteamVR_Camera player = other.GetComponent <SteamVR_Camera>();
         if (player != null)
         {
             Depart();
             trainDepart = true;
         }
     }
 }
Example #31
0
    private void OnPostRender()
    {
        SteamVR  instance     = SteamVR.instance;
        Camera   component    = base.GetComponent <Camera>();
        float    num          = this.scale * component.aspect / instance.aspect;
        float    x            = -this.scale;
        float    x2           = this.scale;
        float    y            = num;
        float    y2           = -num;
        Material blitMaterial = SteamVR_Camera.blitMaterial;

        blitMaterial.mainTexture = SteamVR_Camera.GetSceneTexture(component.hdr);
        GL.PushMatrix();
        GL.LoadOrtho();
        blitMaterial.SetPass(0);
        GL.Begin(7);
        GL.TexCoord2(0f, 0f);
        GL.Vertex3(x, y, 0f);
        GL.TexCoord2(1f, 0f);
        GL.Vertex3(x2, y, 0f);
        GL.TexCoord2(1f, 1f);
        GL.Vertex3(x2, y2, 0f);
        GL.TexCoord2(0f, 1f);
        GL.Vertex3(x, y2, 0f);
        GL.End();
        GL.PopMatrix();
        SteamVR_Overlay instance2 = SteamVR_Overlay.instance;

        if (instance2 && instance2.texture && SteamVR_GameView.overlayMaterial && this.drawOverlay)
        {
            Texture texture = instance2.texture;
            SteamVR_GameView.overlayMaterial.mainTexture = texture;
            float x3 = 0f;
            float y3 = 1f - (float)Screen.height / (float)texture.height;
            float x4 = (float)Screen.width / (float)texture.width;
            float y4 = 1f;
            GL.PushMatrix();
            GL.LoadOrtho();
            SteamVR_GameView.overlayMaterial.SetPass((QualitySettings.activeColorSpace != ColorSpace.Linear) ? 0 : 1);
            GL.Begin(7);
            GL.TexCoord2(x3, y3);
            GL.Vertex3(-1f, -1f, 0f);
            GL.TexCoord2(x4, y3);
            GL.Vertex3(1f, -1f, 0f);
            GL.TexCoord2(x4, y4);
            GL.Vertex3(1f, 1f, 0f);
            GL.TexCoord2(x3, y4);
            GL.Vertex3(-1f, 1f, 0f);
            GL.End();
            GL.PopMatrix();
        }
    }
	void AddInternal(SteamVR_Camera vrcam)
	{
		var camera = vrcam.GetComponent<Camera>();
		var length = cameras.Length;
		var sorted = new SteamVR_Camera[length + 1];
		int insert = 0;
		for (int i = 0; i < length; i++)
		{
			var c = cameras[i].GetComponent<Camera>();
			if (i == insert && c.depth > camera.depth)
				sorted[insert++] = vrcam;

			sorted[insert++] = cameras[i];
		}
		if (insert == length)
			sorted[insert] = vrcam;

		cameras = sorted;
	}
 public static void Remove(SteamVR_Camera vrcam)
 {
     if (!isQuitting && _instance != null)
         instance.RemoveInternal(vrcam);
 }
 public static void Add(SteamVR_Camera vrcam)
 {
     if (!isQuitting)
         instance.AddInternal(vrcam);
 }
    void RemoveInternal(SteamVR_Camera vrcam)
    {
        var length = cameras.Length;
        int count = 0;
        for (int i = 0; i < length; i++)
        {
            var c = cameras[i];
            if (c == vrcam)
                ++count;
        }
        if (count == 0)
            return;

        var sorted = new SteamVR_Camera[length - count];
        int insert = 0;
        for (int i = 0; i < length; i++)
        {
            var c = cameras[i];
            if (c != vrcam)
                sorted[insert++] = c;
        }

        cameras = sorted;
    }