Manager class with API for recognizing user gestures.
private void Transition(MRWSAInput.GestureRecognizer newRecognizer) { if (newRecognizer != null && this.activeRecognizer == newRecognizer && this.IsCapturingGestures) { return; } if (this.activeRecognizer != null) { if (this.activeRecognizer == newRecognizer) { return; } this.activeRecognizer.CancelGestures(); this.activeRecognizer.StopCapturingGestures(); } if (newRecognizer != null) { newRecognizer.StartCapturingGestures(); } this.activeRecognizer = newRecognizer; }
// Use this for initialization void Start() { // Set up a GestureRecognizer to detect Select gestures. gestureRecognizer = new UnityEngine.VR.WSA.Input.GestureRecognizer(); gestureRecognizer.TappedEvent += GestureRecognizer_TappedEvent; gestureRecognizer.StartCapturingGestures(); }
// 仮 void Awake() { InputActionRecognizer = new UnityEngine.VR.WSA.Input.GestureRecognizer(); InputActionRecognizer.SetRecognizableGestures(UnityEngine.VR.WSA.Input.GestureSettings.Hold); InputActionRecognizer.HoldStartedEvent += InputActionRecognizer_HoldStartEvent; InputActionRecognizer.HoldCompletedEvent += InputActionRecognizer_HoldCompletedEvent; }
private void Awake() { // Instantiate the Navigation recognizer this.navigationRecognizer = new MRWSAInput.GestureRecognizer(); this.navigationRecognizer.SetRecognizableGestures( MRWSAInput.GestureSettings.Tap | MRWSAInput.GestureSettings.DoubleTap | MRWSAInput.GestureSettings.NavigationX | MRWSAInput.GestureSettings.NavigationY | MRWSAInput.GestureSettings.NavigationZ); // Instantiate the Manipulation Recognizer. this.manipulationRecognizer = new MRWSAInput.GestureRecognizer(); this.manipulationRecognizer.SetRecognizableGestures( MRWSAInput.GestureSettings.Tap | MRWSAInput.GestureSettings.DoubleTap | MRWSAInput.GestureSettings.ManipulationTranslate); #if UNITY_5 this.navigationRecognizer.TappedEvent += this.Recognizer_TappedEvent; this.navigationRecognizer.NavigationStartedEvent += this.NavigationRecognizer_NavigationStartedEvent; this.navigationRecognizer.NavigationUpdatedEvent += this.NavigationRecognizer_NavigationUpdatedEvent; this.navigationRecognizer.NavigationCompletedEvent += this.NavigationRecognizer_NavigationCompletedEvent; this.navigationRecognizer.NavigationCanceledEvent += this.NavigationRecognizer_NavigationCanceledEvent; this.manipulationRecognizer.TappedEvent += this.Recognizer_TappedEvent; this.manipulationRecognizer.ManipulationStartedEvent += this.ManipulationRecognizer_ManipulationStartedEvent; this.manipulationRecognizer.ManipulationUpdatedEvent += this.ManipulationRecognizer_ManipulationUpdatedEvent; this.manipulationRecognizer.ManipulationCompletedEvent += this.ManipulationRecognizer_ManipulationCompletedEvent; this.manipulationRecognizer.ManipulationCanceledEvent += this.ManipulationRecognizer_ManipulationCanceledEvent; // interaction manager state handling MRWSAInput.InteractionManager.SourcePressed += InteractionManager_SourcePressed; MRWSAInput.InteractionManager.SourceReleased += InteractionManager_SourceReleased; #else this.navigationRecognizer.Tapped += this.Recognizer_TappedEvent; this.navigationRecognizer.NavigationStarted += this.NavigationRecognizer_NavigationStartedEvent; this.navigationRecognizer.NavigationUpdated += this.NavigationRecognizer_NavigationUpdatedEvent; this.navigationRecognizer.NavigationCompleted += this.NavigationRecognizer_NavigationCompletedEvent; this.navigationRecognizer.NavigationCanceled += this.NavigationRecognizer_NavigationCanceledEvent; this.manipulationRecognizer.Tapped += this.Recognizer_TappedEvent; this.manipulationRecognizer.ManipulationStarted += this.ManipulationRecognizer_ManipulationStartedEvent; this.manipulationRecognizer.ManipulationUpdated += this.ManipulationRecognizer_ManipulationUpdatedEvent; this.manipulationRecognizer.ManipulationCompleted += this.ManipulationRecognizer_ManipulationCompletedEvent; this.manipulationRecognizer.ManipulationCanceled += this.ManipulationRecognizer_ManipulationCanceledEvent; // interaction manager state handling MRWSAInput.InteractionManager.InteractionSourcePressed += InteractionManager_SourcePressed; MRWSAInput.InteractionManager.InteractionSourceReleased += InteractionManager_SourceReleased; #endif }
private static extern void INTERNAL_CALL_Internal_Create(GestureRecognizer self, out IntPtr value);
private void Awake() { gestureRecognizer = new 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(GestureSettings.Tap | GestureSettings.ManipulationTranslate | GestureSettings.Hold); gestureRecognizer.StartCapturingGestures(); // We need a separate gesture recognizer for navigation, since it isn't compatible with manipulation navigationGestureRecognizer = new GestureRecognizer(); navigationGestureRecognizer.NavigationStartedEvent += OnNavigationStartedEvent; navigationGestureRecognizer.NavigationUpdatedEvent += OnNavigationUpdatedEvent; navigationGestureRecognizer.NavigationCompletedEvent += OnNavigationCompletedEvent; navigationGestureRecognizer.NavigationCanceledEvent += OnNavigationCanceledEvent; if (UseRailsNavigation) { navigationGestureRecognizer.SetRecognizableGestures(GestureSettings.NavigationRailsX | GestureSettings.NavigationRailsY | GestureSettings.NavigationRailsZ); } else { navigationGestureRecognizer.SetRecognizableGestures(GestureSettings.NavigationX | GestureSettings.NavigationY | GestureSettings.NavigationZ); } navigationGestureRecognizer.StartCapturingGestures(); }