Пример #1
0
        private void Start()
        {
            levelSwitching = GameObject.Find("mainGameController").GetComponent <LevelSwitching>();
            if (pose == null)
            {
                pose = this.GetComponent <SteamVR_Behaviour_Pose>();
            }
            if (pose == null)
            {
                Debug.LogError("No SteamVR_Behaviour_Pose component found on this object");
            }

            if (interactWithUI == null)
            {
                Debug.LogError("No ui interaction action has been set on this component.");
            }


            holder = new GameObject();
            holder.transform.parent        = this.transform;
            holder.transform.localPosition = Vector3.zero;
            holder.transform.localRotation = Quaternion.identity;

            pointer = GameObject.CreatePrimitive(PrimitiveType.Cube);
            pointer.transform.parent        = holder.transform;
            pointer.transform.localScale    = new Vector3(thickness, thickness, 100f);
            pointer.transform.localPosition = new Vector3(0f, 0f, 50f);
            pointer.transform.localRotation = Quaternion.identity;
            BoxCollider collider = pointer.GetComponent <BoxCollider>();

            if (addRigidBody)
            {
                if (collider)
                {
                    collider.isTrigger = true;
                }
                Rigidbody rigidBody = pointer.AddComponent <Rigidbody>();
                rigidBody.isKinematic = true;
            }
            else
            {
                if (collider)
                {
                    UnityEngine.Object.Destroy(collider);
                }
            }
            Material newMaterial = new Material(Shader.Find("Unlit/Color"));

            newMaterial.SetColor("_Color", color);
            pointer.GetComponent <MeshRenderer>().material = newMaterial;
        }
Пример #2
0
 // Start is called before the first frame update
 void Start()
 {
     levelSwitching = GameObject.Find("mainGameController").GetComponent <LevelSwitching>();
 }