private void InitializeInternal()
        {
#if UNITY_EDITOR
            if (!UnityEditor.EditorApplication.isPlaying)
            {
                var eventSystems = Object.FindObjectsOfType <EventSystem>();

                if (eventSystems.Length == 0)
                {
                    if (!IsInputSystemEnabled)
                    {
                        eventSystemReference = new GameObject("Event System");
                        eventSystemReference.AddComponent <EventSystem>();
                    }
                    else
                    {
                        Debug.Log("The Input System didn't properly add an event system to your scene. Please make sure the Input System's priority is set higher than the teleport system.");
                    }
                }
                else if (eventSystems.Length > 1)
                {
                    Debug.Log("Too many event systems in the scene. The Teleport System requires only one.");
                }
            }
#endif // UNITY_EDITOR

            teleportEventData = new TeleportEventData(EventSystem.current);
        }
        private void ProcessTeleportationRequest(TeleportEventData eventData)
        {
            isProcessingTeleportRequest = true;

            var cameraParent = Playspace;

            targetRotation   = Vector3.zero;
            targetRotation.y = eventData.Pointer.PointerOrientation;
            targetPosition   = eventData.Pointer.Result.Details.Point;

            if (eventData.HotSpot != null)
            {
                targetPosition = eventData.HotSpot.Position;

                if (eventData.HotSpot.OverrideTargetOrientation)
                {
                    targetRotation.y = eventData.HotSpot.TargetOrientation;
                }
            }

            float height = targetPosition.y;

            targetPosition       -= CameraCache.Main.transform.position - cameraParent.position;
            targetPosition.y      = height;
            cameraParent.position = targetPosition;

            cameraParent.RotateAround(CameraCache.Main.transform.position, Vector3.up, targetRotation.y - CameraCache.Main.transform.eulerAngles.y);

            isProcessingTeleportRequest = false;

            // Raise complete event using the pointer and hot spot provided.
            RaiseTeleportComplete(eventData.Pointer, eventData.HotSpot);
        }
 /// <inheritdoc />
 public virtual void OnTeleportCompleted(TeleportEventData eventData)
 {
     using (OnTeleportCompletedPerfMarker.Auto())
     {
         isTeleportRequestActive = false;
         BaseCursor?.SetVisibility(false);
     }
 }
 /// <inheritdoc />
 public virtual void OnTeleportStarted(TeleportEventData eventData)
 {
     using (OnTeleportStartedPerfMarker.Auto())
     {
         // Turn off all pointers while we teleport.
         isTeleportRequestActive = true;
         BaseCursor?.SetVisibility(false);
     }
 }
 /// <inheritdoc />
 public override void OnTeleportRequest(TeleportEventData eventData)
 {
     // Only turn off the pointer if we're not the one sending the request
     if (eventData.Pointer.PointerId == PointerId)
     {
         IsTeleportRequestActive = false;
     }
     else
     {
         IsTeleportRequestActive = true;
         BaseCursor?.SetVisibility(false);
     }
 }
 /// <inheritdoc />
 public virtual void OnTeleportRequest(TeleportEventData eventData)
 {
     using (OnTeleportRequestPerfMarker.Auto())
     {
         // Only turn off the pointer if we're not the one sending the request
         if (eventData.Pointer.PointerId == PointerId)
         {
             isTeleportRequestActive = false;
             BaseCursor?.SetVisibility(true);
         }
         else
         {
             isTeleportRequestActive = true;
             BaseCursor?.SetVisibility(false);
         }
     }
 }
 /// <inheritdoc />
 public override void OnTeleportCanceled(TeleportEventData eventData)
 {
     IsTeleportRequestActive = false;
     BaseCursor?.SetVisibility(false);
 }
Beispiel #8
0
 /// <inheritdoc />
 public void OnTeleportCanceled(TeleportEventData eventData)
 {
     OnCursorStateChange(CursorStateEnum.Release);
 }
Beispiel #9
0
 /// <inheritdoc />
 public void OnTeleportCompleted(TeleportEventData eventData)
 {
 }
Beispiel #10
0
 /// <inheritdoc />
 public void OnTeleportRequest(TeleportEventData eventData)
 {
     OnCursorStateChange(CursorStateEnum.Observe);
 }
Beispiel #11
0
 /// <inheritdoc />
 public virtual void OnTeleportCanceled(TeleportEventData eventData)
 {
     isTeleportRequestActive = false;
     BaseCursor?.SetVisibility(false);
 }