private void Start()
 {
     recognizer = new UnityEngine.XR.WSA.Input.GestureRecognizer();
     recognizer.SetRecognizableGestures(UnityEngine.XR.WSA.Input.GestureSettings.Tap);
     recognizer.TappedEvent += Recognizer_TappedEvent;
     recognizer.StartCapturingGestures();
 }
        // This should be Start instead of Awake right?
        protected void Start()
        {
            ActiveRecognizer = new UnityEngine.XR.WSA.Input.GestureRecognizer();

            ActiveRecognizer.SetRecognizableGestures(RecognizableGesures);

            ActiveRecognizer.TappedEvent += TappedCallback;

            ActiveRecognizer.NavigationStartedEvent   += NavigationStartedCallback;
            ActiveRecognizer.NavigationUpdatedEvent   += NavigationUpdatedCallback;
            ActiveRecognizer.NavigationCompletedEvent += NavigationCompletedCallback;
            ActiveRecognizer.NavigationCanceledEvent  += NavigationCanceledCallback;

            ActiveRecognizer.HoldStartedEvent   += HoldStartedCallback;
            ActiveRecognizer.HoldCompletedEvent += HoldCompletedCallback;
            ActiveRecognizer.HoldCanceledEvent  += HoldCanceledCallback;

            ActiveRecognizer.ManipulationStartedEvent   += ManipulationStartedCallback;
            ActiveRecognizer.ManipulationUpdatedEvent   += ManipulationUpdatedCallback;
            ActiveRecognizer.ManipulationCompletedEvent += ManipulationCompletedCallback;
            ActiveRecognizer.ManipulationCanceledEvent  += ManipulationCanceledCallback;

            ActiveRecognizer.StartCapturingGestures();
            SetupEvents(true);

            UnityEngine.XR.WSA.Input.InteractionManager.InteractionSourcePressed  += InteractionManager_SourcePressedCallback;
            UnityEngine.XR.WSA.Input.InteractionManager.InteractionSourceReleased += InteractionManager_SourceReleasedCallback;

            bLockFocus = true;
        }
Exemple #3
0
 /// <summary>
 /// Make sure the gesture recognizer is off, then start it.
 /// Otherwise, leave it alone because it's already in the desired state.
 /// </summary>
 public void StartGestureRecognizer()
 {
     if (gestureRecognizer != null && !gestureRecognizer.IsCapturingGestures())
     {
         gestureRecognizer.StartCapturingGestures();
     }
     if (navigationGestureRecognizer != null && !navigationGestureRecognizer.IsCapturingGestures())
     {
         navigationGestureRecognizer.StartCapturingGestures();
     }
 }
        /// <summary>
        /// Make sure the gesture recognizer is off, then start it.
        /// Otherwise, leave it alone because it's already in the desired state.
        /// </summary>
        public void StartGestureRecognizer()
        {
#if UNITY_EDITOR || UNITY_WSA
            if (gestureRecognizer != null && !gestureRecognizer.IsCapturingGestures())
            {
                gestureRecognizer.StartCapturingGestures();
            }
            if (navigationGestureRecognizer != null && !navigationGestureRecognizer.IsCapturingGestures())
            {
                navigationGestureRecognizer.StartCapturingGestures();
            }
#endif
        }
        public static void UpdateAndResetGestures(this UnityEngine.XR.WSA.Input.GestureRecognizer recognizer, UnityEngine.XR.WSA.Input.GestureSettings gestureSettings)
        {
            bool reset = recognizer.IsCapturingGestures();

            if (reset)
            {
                recognizer.CancelGestures();
            }

            recognizer.SetRecognizableGestures(gestureSettings);

            if (reset)
            {
                recognizer.StartCapturingGestures();
            }
        }
        protected override void Start()
        {
            base.Start();

            gestureRecognizer              = new UnityEngine.XR.WSA.Input.GestureRecognizer();
            gestureRecognizer.TappedEvent += OnTappedEvent;

            gestureRecognizer.HoldStartedEvent   += OnHoldStartedEvent;
            gestureRecognizer.HoldCompletedEvent += OnHoldCompletedEvent;
            gestureRecognizer.HoldCanceledEvent  += OnHoldCanceledEvent;

            gestureRecognizer.ManipulationStartedEvent   += OnManipulationStartedEvent;
            gestureRecognizer.ManipulationUpdatedEvent   += OnManipulationUpdatedEvent;
            gestureRecognizer.ManipulationCompletedEvent += OnManipulationCompletedEvent;
            gestureRecognizer.ManipulationCanceledEvent  += OnManipulationCanceledEvent;

            gestureRecognizer.SetRecognizableGestures(UnityEngine.XR.WSA.Input.GestureSettings.Tap |
                                                      UnityEngine.XR.WSA.Input.GestureSettings.ManipulationTranslate |
                                                      UnityEngine.XR.WSA.Input.GestureSettings.Hold);

            // We need a separate gesture recognizer for navigation, since it isn't compatible with manipulation
            navigationGestureRecognizer = new UnityEngine.XR.WSA.Input.GestureRecognizer();

            navigationGestureRecognizer.NavigationStartedEvent   += OnNavigationStartedEvent;
            navigationGestureRecognizer.NavigationUpdatedEvent   += OnNavigationUpdatedEvent;
            navigationGestureRecognizer.NavigationCompletedEvent += OnNavigationCompletedEvent;
            navigationGestureRecognizer.NavigationCanceledEvent  += OnNavigationCanceledEvent;

            if (UseRailsNavigation)
            {
                navigationGestureRecognizer.SetRecognizableGestures(UnityEngine.XR.WSA.Input.GestureSettings.NavigationRailsX |
                                                                    UnityEngine.XR.WSA.Input.GestureSettings.NavigationRailsY |
                                                                    UnityEngine.XR.WSA.Input.GestureSettings.NavigationRailsZ);
            }
            else
            {
                navigationGestureRecognizer.SetRecognizableGestures(UnityEngine.XR.WSA.Input.GestureSettings.NavigationX |
                                                                    UnityEngine.XR.WSA.Input.GestureSettings.NavigationY |
                                                                    UnityEngine.XR.WSA.Input.GestureSettings.NavigationZ);
            }

            if (RecognizerStart == RecognizerStartBehavior.AutoStart)
            {
                gestureRecognizer.StartCapturingGestures();
                navigationGestureRecognizer.StartCapturingGestures();
            }
        }
Exemple #7
0
        public override void ActivateModule()
        {
            base.ActivateModule();

            eventSystem.SetSelectedGameObject(eventSystem.currentSelectedGameObject, GetBaseEventData());

            m_GestureRecognizer                           = new UnityEngine.XR.WSA.Input.GestureRecognizer();
            m_GestureRecognizer.TappedEvent              += GestureHandler_Tapped;
            m_GestureRecognizer.NavigationStartedEvent   += GestureHandler_NavigationStarted;
            m_GestureRecognizer.NavigationUpdatedEvent   += GestureHandler_NavigationUpdated;
            m_GestureRecognizer.NavigationCompletedEvent += GestureHandler_NavigationCompletedOrCanceled;
            m_GestureRecognizer.NavigationCanceledEvent  += GestureHandler_NavigationCompletedOrCanceled;
            m_GestureRecognizer.SetRecognizableGestures(
                UnityEngine.XR.WSA.Input.GestureSettings.Tap
                | UnityEngine.XR.WSA.Input.GestureSettings.NavigationX
                | UnityEngine.XR.WSA.Input.GestureSettings.NavigationY
                | UnityEngine.XR.WSA.Input.GestureSettings.NavigationZ);
            m_GestureRecognizer.StartCapturingGestures();
        }
 //method to transition to a new GestureRecognizer
 public void Transition(UnityEngine.XR.WSA.Input.GestureRecognizer newRecognizer)
 {
     //check if input parameter is null
     if (newRecognizer == null)
     {
         return;
     }
     if (ActiveRecognizer != null)
     {
         //if the active recognizer isn't null and not the same as the new recognizer cancel all gesures and complete the switch
         if (ActiveRecognizer == newRecognizer)
         {
             return;
         }
         ActiveRecognizer.CancelGestures();
         ActiveRecognizer = newRecognizer;
     }
     newRecognizer.StartCapturingGestures();
     ActiveRecognizer = newRecognizer;
 }
Exemple #9
0
        public void SetActiveRecognizer(UnityEngine.XR.WSA.Input.GestureRecognizer newRecognizer)
        {
            if (newRecognizer == null)
            {
                return;
            }

            if (ActiveRecognizer != null)
            {
                if (ActiveRecognizer == newRecognizer)
                {
                    return;
                }

                ActiveRecognizer.CancelGestures();
                ActiveRecognizer.StopCapturingGestures();
            }

            newRecognizer.StartCapturingGestures();
            ActiveRecognizer = newRecognizer;
        }