Пример #1
0
 /// <summary>
 /// Revert back to the default GestureRecognizer.
 /// </summary>
 public void ResetGestureRecognizers()
 {
     // Default to the manipulation gestures.
     //Transition(ManipulationRecognizer);
     ActiveRecognizer = ManipulationRecognizer;
     ActiveRecognizer.StartCapturingGestures();
 }
        void LateUpdate()
        {
            GameObject oldFocusedObject = focusedObject;

            if (GazeManager.Instance.Hit &&
                OverrideFocusedObject == null &&
                GazeManager.Instance.HitInfo.collider != null)
            {
                // If gaze hits a hologram, set the focused object to that game object.
                // Also if the caller has not decided to override the focused object.
                focusedObject = GazeManager.Instance.HitInfo.collider.gameObject;
            }
            else
            {
                // If our gaze doesn't hit a hologram, set the focused object to null or override focused object.
                focusedObject = OverrideFocusedObject;
            }

            if (focusedObject != oldFocusedObject)
            {
                // If the currently focused object doesn't match the old focused object, cancel the current gesture.
                // Start looking for new gestures.  This is to prevent applying gestures from one hologram to another.
                ActiveRecognizer.CancelGestures();
                ActiveRecognizer.StartCapturingGestures();
            }
        }
Пример #3
0
        void Start()
        {
            // Create a new GestureRecognizer. Sign up for tapped events.
            ClickRecognizer = new UnityEngine.VR.WSA.Input.GestureRecognizer();
            ClickRecognizer.SetRecognizableGestures(UnityEngine.VR.WSA.Input.GestureSettings.Tap);
            ClickRecognizer.TappedEvent += ClickRecognizer_TappedEvent;

            // Move Gesture
            MoveRecognizer = new UnityEngine.VR.WSA.Input.GestureRecognizer();
            MoveRecognizer.SetRecognizableGestures(UnityEngine.VR.WSA.Input.GestureSettings.ManipulationTranslate);
            MoveRecognizer.ManipulationStartedEvent   += MoveRecognizer_ManipulationStartedEvent;
            MoveRecognizer.ManipulationUpdatedEvent   += MoveRecognizer_ManipulationUpdatedEvent;
            MoveRecognizer.ManipulationCompletedEvent += MoveRecognizer_ManipulationCompletedEvent;
            MoveRecognizer.ManipulationCanceledEvent  += MoveRecognizer_ManipulationCanceledEvent;

            // Rotate Gestrue
            RotateRecognizer = new UnityEngine.VR.WSA.Input.GestureRecognizer();
            RotateRecognizer.SetRecognizableGestures(UnityEngine.VR.WSA.Input.GestureSettings.NavigationX);
            RotateRecognizer.NavigationStartedEvent   += RotateRecognizer_NavigationStartedEvent;
            RotateRecognizer.NavigationUpdatedEvent   += RotateRecognizer_NavigationUpdatedEvent;
            RotateRecognizer.NavigationCompletedEvent += RotateRecognizer_NavigationCompletedEvent;
            RotateRecognizer.NavigationCanceledEvent  += RotateRecognizer_NavigationCanceledEvent;

            // Zoom Gesture
            ZoomRecognizer = new UnityEngine.VR.WSA.Input.GestureRecognizer();
            ZoomRecognizer.SetRecognizableGestures(UnityEngine.VR.WSA.Input.GestureSettings.NavigationY);
            ZoomRecognizer.NavigationStartedEvent   += ZoomRecognizer_NavigationStartedEvent;
            ZoomRecognizer.NavigationUpdatedEvent   += ZoomRecognizer_NavigationUpdatedEvent;
            ZoomRecognizer.NavigationCompletedEvent += ZoomRecognizer_NavigationCompletedEvent;
            ZoomRecognizer.NavigationCanceledEvent  += ZoomRecognizer_NavigationCanceledEvent;

            // Save Gesture
            SaveRecognizer = new UnityEngine.VR.WSA.Input.GestureRecognizer();
            SaveRecognizer.SetRecognizableGestures(UnityEngine.VR.WSA.Input.GestureSettings.Tap);
            SaveRecognizer.TappedEvent += SaveRecognizer_TappedEvent;

            // Start looking for gestures.
            IsClicking       = true;
            ActiveRecognizer = ClickRecognizer;
            ActiveRecognizer.StartCapturingGestures();
        }