Ejemplo n.º 1
0
        private void AddTeleporter()
        {
            Teleporter teleporter = Teleporter.Add(headTarget.transform, InteractionPointer.PointerType.FocusPoint);

            if (headTarget.unityVRHead.cameraTransform != null)
            {
                teleporter.transform.position = headTarget.unityVRHead.cameraTransform.position;
                teleporter.transform.rotation = headTarget.unityVRHead.cameraTransform.rotation;
            }
            teleporter.focusPointObj.transform.localPosition = new Vector3(0, 0, 2);

            HeadInput.Add(headTarget.transform);

            ControllerInput controllerInput = headTarget.humanoid.GetComponent <ControllerInput>();

            if (controllerInput != null)
            {
                controllerInput.leftButtonOneInput.SetMethod(teleporter.Click, InputEvent.EventType.Start);
            }
        }
        public static new Teleporter Add(Transform parentTransform, PointerType pointerType = PointerType.Ray)
        {
            GameObject pointerObj = new GameObject("Teleporter");

            pointerObj.transform.SetParent(parentTransform, false);

            GameObject destinationObj = new GameObject("Destination");

            destinationObj.transform.SetParent(pointerObj.transform);
            destinationObj.transform.localPosition = Vector3.zero;
            destinationObj.transform.localRotation = Quaternion.identity;

            if (pointerType == PointerType.FocusPoint)
            {
                GameObject focusPointSphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                focusPointSphere.transform.SetParent(destinationObj.transform);
                focusPointSphere.transform.localPosition = Vector3.zero;
                focusPointSphere.transform.localRotation = Quaternion.identity;
                focusPointSphere.transform.localScale    = Vector3.one * 0.1F;
            }
            else
            {
                LineRenderer pointerRay = destinationObj.AddComponent <LineRenderer>();
                pointerRay.startWidth        = 0.01F;
                pointerRay.endWidth          = 0.01F;
                pointerRay.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
                pointerRay.receiveShadows    = false;
                pointerRay.useWorldSpace     = false;
            }

            Teleporter teleporter = pointerObj.AddComponent <Teleporter>();

            teleporter.focusPointObj = destinationObj;
            teleporter.rayType       = RayType.Bezier;

            return(teleporter);
        }