示例#1
0
        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);
        }
示例#2
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);
    }