示例#1
0
        protected virtual void SetupHeadset()
        {
            Rigidbody headsetRigidbody = headset.GetComponentInChildren <Rigidbody>();

            if (headsetRigidbody == null)
            {
                CreateHeadsetColliderContainer();
                headsetRigidbody             = headsetColliderContainer.AddComponent <Rigidbody>();
                headsetRigidbody.constraints = RigidbodyConstraints.FreezeAll;
                generateRigidbody            = true;
            }
            headsetRigidbody.isKinematic = true;
            headsetRigidbody.useGravity  = false;

            Collider headsetCollider = headset.GetComponentInChildren <Collider>();

            if (headsetCollider == null)
            {
                CreateHeadsetColliderContainer();
                SphereCollider newCollider = headsetColliderContainer.gameObject.AddComponent <SphereCollider>();
                newCollider.radius = colliderRadius;
                headsetCollider    = newCollider;
                generateCollider   = true;
            }
            headsetCollider.isTrigger = true;

            if (headsetColliderScript == null)
            {
                GameObject attachTo = (headsetColliderContainer ? headsetColliderContainer : headset.gameObject);
                headsetColliderScript = attachTo.AddComponent <VRTK_HeadsetCollider>();
                headsetColliderScript.SetParent(gameObject);
                headsetColliderScript.SetIgnoreTarget(targetListPolicy);
            }
        }
示例#2
0
        private void SetupHeadset()
        {
            var headsetCollider = headset.GetComponent <Collider>();

            if (!headsetCollider)
            {
                var newCollider = headset.gameObject.AddComponent <BoxCollider>();
                newCollider.size = new Vector3(0.1f, 0.1f, 0.1f);
                headsetCollider  = newCollider;
                generateCollider = true;
            }
            headsetCollider.isTrigger = true;

            var headsetRigidbody = headset.GetComponent <Rigidbody>();

            if (!headsetRigidbody)
            {
                headsetRigidbody  = headset.gameObject.AddComponent <Rigidbody>();
                generateRigidbody = true;
            }
            headsetRigidbody.isKinematic = true;
            headsetRigidbody.useGravity  = false;

            if (!headsetColliderScript)
            {
                headsetColliderScript = headset.gameObject.AddComponent <VRTK_HeadsetCollider>();
                headsetColliderScript.SetParent(gameObject);
                headsetColliderScript.SetIgnoreTarget(ignoreTargetWithTagOrClass, targetTagOrScriptListPolicy);
            }
        }
        private void SetupHeadset()
        {
            var headsetCollider = headset.GetComponent<Collider>();
            if (!headsetCollider)
            {
                var newCollider = headset.gameObject.AddComponent<BoxCollider>();
                newCollider.size = new Vector3(0.1f, 0.1f, 0.1f);
                headsetCollider = newCollider;
                generateCollider = true;
            }
            headsetCollider.isTrigger = true;

            var headsetRigidbody = headset.GetComponent<Rigidbody>();
            if (!headsetRigidbody)
            {
                headsetRigidbody = headset.gameObject.AddComponent<Rigidbody>();
                generateRigidbody = true;
            }
            headsetRigidbody.isKinematic = true;
            headsetRigidbody.useGravity = false;

            if (!headsetColliderScript)
            {
                headsetColliderScript = headset.gameObject.AddComponent<VRTK_HeadsetCollider>();
                headsetColliderScript.SetParent(gameObject);
                headsetColliderScript.SetIgnoreTarget(ignoreTargetWithTagOrClass, targetTagOrScriptListPolicy);
            }
        }