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. ClickRecognizer.CancelGestures(); ClickRecognizer.StartCapturingGestures(); } }
private void SubscribeToClicks() { if (this.clickGestureRecognizer != null && this.NativeUIElement.GestureRecognizers != null && this.NativeUIElement.GestureRecognizers.Contains(this.clickGestureRecognizer)) { return; } this.clickGestureRecognizer = new ClickRecognizer(() => { this.OnClick(); }, this); this.clickGestureRecognizer.CancelsTouchesInView = false; this.NativeUIElement.AddGestureRecognizer(this.clickGestureRecognizer); }
void OnDestroy() { ClickRecognizer.StopCapturingGestures(); ClickRecognizer.TappedEvent -= ClickRecognizer_TappedEvent; MoveRecognizer.ManipulationStartedEvent -= MoveRecognizer_ManipulationStartedEvent; MoveRecognizer.ManipulationUpdatedEvent -= MoveRecognizer_ManipulationUpdatedEvent; MoveRecognizer.ManipulationCompletedEvent -= MoveRecognizer_ManipulationCompletedEvent; MoveRecognizer.ManipulationCanceledEvent -= MoveRecognizer_ManipulationCanceledEvent; RotateRecognizer.NavigationStartedEvent -= RotateRecognizer_NavigationStartedEvent; RotateRecognizer.NavigationUpdatedEvent -= RotateRecognizer_NavigationUpdatedEvent; RotateRecognizer.NavigationCompletedEvent -= RotateRecognizer_NavigationCompletedEvent; RotateRecognizer.NavigationCanceledEvent -= RotateRecognizer_NavigationCanceledEvent; ZoomRecognizer.NavigationStartedEvent -= ZoomRecognizer_NavigationStartedEvent; ZoomRecognizer.NavigationUpdatedEvent -= ZoomRecognizer_NavigationUpdatedEvent; ZoomRecognizer.NavigationCompletedEvent -= ZoomRecognizer_NavigationCompletedEvent; ZoomRecognizer.NavigationCanceledEvent -= ZoomRecognizer_NavigationCanceledEvent; SaveRecognizer.TappedEvent -= SaveRecognizer_TappedEvent; }