// Use this for initialization void Awake() { Instance = this; // Set up a GestureRecognizer to detect Manipulation gestures. recognizer = new GestureRecognizer(); // Add the ManipulationTranslate GestureSetting to the recognizer's RecognizableGestures. recognizer.SetRecognizableGestures( GestureSettings.ManipulationTranslate); // Register for the Manipulation events on the ManipulationRecognizer. recognizer.ManipulationStartedEvent += Recognizer_ManipulationStartedEvent; recognizer.ManipulationUpdatedEvent += Recognizer_ManipulationUpdatedEvent; recognizer.ManipulationCompletedEvent += Recognizer_ManipulationCompletedEvent; recognizer.ManipulationCanceledEvent += Recognizer_ManipulationCanceledEvent; recognizer.TappedEvent += (source, tapCount, ray) => { // Send an OnSelect message to the focused object and its ancestors. if (FocusedObject != null) { FocusedObject.SendMessageUpwards("OnSelect"); } }; recognizer.StartCapturingGestures(); }
private void Update() { Ray currentMouseRaycast = Camera.main.ScreenPointToRay( Input.mousePosition, Camera.MonoOrStereoscopicEye.Mono); if (Physics.Raycast(currentMouseRaycast, out RaycastHit hoverObject, 1000f, LayerMask.GetMask("Interactable"))) { InteractableObject sceneItem = hoverObject.transform. GetComponent <InteractableObject>(); if (sceneItem == null) { Debug.Log("ALL OBJECTS IN THE INTERACTABLE LAYER SHOULD BE INTERACTABLEOBJECTS YOU MORON!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); return; } if (currentlyFocusedItem == null) { currentlyFocusedItem = new FocusedObject(); } else { currentlyFocusedItem.focusedGameObject.ClearFocus(); } currentlyFocusedItem.focusedGameObject = sceneItem; currentlyFocusedItem.focusedWorldPoint = hoverObject.point; sceneItem.SetFocus(); }
// Use this for initialization void Awake() { Instance = this; this.textMesh = this.textMeshObject.GetComponent <TextMesh>(); audiosource = GetComponent <AudioSource>(); // Set up a GestureRecognizer to detect Select gestures. TapRecognizer = new UnityEngine.XR.WSA.Input.GestureRecognizer(); ManipulationRecognizer = new UnityEngine.XR.WSA.Input.GestureRecognizer(); TapRecognizer.TappedEvent += (source, tapCount, ray) => { // Send an OnSelect message to the focused object and its ancestors. if (FocusedObject != null) { FocusedObject.SendMessageUpwards("OnSelect"); Debug.Log("On select called: " + FocusedObject.name); } else { Debug.Log("Focused object is null"); } }; ManipulationRecognizer.SetRecognizableGestures( UnityEngine.XR.WSA.Input.GestureSettings.ManipulationTranslate); ManipulationRecognizer.ManipulationStartedEvent += ManipulationRecognizer_ManipulationStartedEvent; ManipulationRecognizer.ManipulationUpdatedEvent += ManipulationRecognizer_ManipulationUpdatedEvent; ManipulationRecognizer.ManipulationCompletedEvent += ManipulationRecognizer_ManipulationCompletedEvent; ManipulationRecognizer.ManipulationCanceledEvent += ManipulationRecognizer_ManipulationCanceledEvent; TapRecognizer.StartCapturingGestures(); ManipulationRecognizer.StartCapturingGestures(); }
private void OnTap() { if (FocusedObject != null) { FocusedObject.SendMessage("OnSelect"); } }
private void GestureRecognizer_TappedEvent(InteractionSourceKind source, int tapCount, Ray headRay) { if (FocusedObject != null) { FocusedObject.SendMessage("OnAirTapped", SendMessageOptions.RequireReceiver); } }
private void OnTap() { /*if (FocusedObject != null && PreviousObject == null && FocusedObject.GetComponent<PerformAction>().GotTransform == false) * { * PreviousObject = FocusedObject.name; * FocusedObject.SendMessage("ObjectAction",FocusedObject.name); * * } else if (FocusedObject != null && FocusedObject.name == PreviousObject && FocusedObject.GetComponent<PerformAction>().GotTransform == true) * { * PreviousObject = null; * FocusedObject.SendMessage("ObjectAction",FocusedObject.name); * * }*/ try { if (FocusedObject != null && FocusedObject.GetComponent <PerformAction> ().GotTransform == false && FocusedObject.transform.parent != GameObject.Find("Chair").transform) { //PreviousObject = FocusedObject.name; //(Behaviour)FocusedObject.GetComponent(Halo); FocusedObject.SendMessage("ObjectAction", FocusedObject.name); } } catch (NullReferenceException e) { print(e.Message); } }
private void OnTap() { if (FocusedObject != null) { FocusedObject.SendMessage("OnSelect", SendMessageOptions.DontRequireReceiver); } }
// Use this for initialization void Awake() { Instance = this; // Set up a GestureRecognizer to detect Select gestures. recognizer = new GestureRecognizer(); recognizer.TappedEvent += (source, tapCount, ray) => { // clear last selected object if (LastClickedObject != FocusedObject && LastClickedObject != null) { LastClickedObject.SendMessageUpwards("OnSelect", SendMessageOptions.DontRequireReceiver); } // Send an OnSelect message to the focused object and its ancestors. if (FocusedObject != null) { FocusedObject.SendMessageUpwards("OnSelect", SendMessageOptions.DontRequireReceiver); //Debug.Log("OnSelect message sent to " + FocusedObject.name); } if (FocusedObject.GetComponent <NodeProperties>() != null || (FocusedObject.GetComponent <BlockProperties>() != null)) { // only save nodes and blocks LastClickedObject = FocusedObject; } else { LastClickedObject = null; } }; recognizer.StartCapturingGestures(); }
// Update is called once per frame void Update() { // Figure out which hologram is focused this frame. FocusedObject = gazeTracker.FocusedObject; if (Application.platform == RuntimePlatform.WindowsEditor) // Do this is running on Unity { // Send an OnSelect message to the focused object and its ancestors if a mouse right click was detected. if (FocusedObject != null && mouseDetector.RightClickDetected == true) { FocusedObject.SendMessageUpwards("OnSelect", SendMessageOptions.DontRequireReceiver); } mouseDetector.RightClickDetected = false; } else // Do this if running on the HoloLens { // If the focused object changed this frame, // start detecting fresh gestures again. if (FocusedObject != PreviousFocusedObject) { // If in HoloLens Message is sent to FocusedObject through the registration of GestureManagers.Trapped recognizer.CancelGestures(); recognizer.StartCapturingGestures(); } } }
// Use this for initialization void Awake() { Instance = this; // Set up a GestureRecognizer to detect Select gestures. recognizer = new GestureRecognizer(); recognizer.SetRecognizableGestures(GestureSettings.Tap | GestureSettings.ManipulationTranslate); recognizer.ManipulationStartedEvent += Recognizer_ManipulationStartedEvent; recognizer.ManipulationCompletedEvent += Recognizer_ManipulationCompletedEvent; recognizer.ManipulationCanceledEvent += Recognizer_ManipulationCompletedEvent; recognizer.ManipulationUpdatedEvent += Recognizer_ManipulationUpdatedEvent; recognizer.TappedEvent += (source, tapCount, ray) => { if (FocusedObject != null) // de-select previously selected object { var selectable = FocusedObject.GetComponent <Selectable>(); if (selectable != null) { if (HasSelection) { selectable.Deselect(); // notify object of deselection FocusedObject = null; HasSelection = false; } else // select new object { selectable.Select(); // notify object of selection HasSelection = true; } } } }; recognizer.StartCapturingGestures(); }
public Vector3 PhysicalPositionToWorldPosition(Vector3 physical_position) { Satellite root_satellite = Root.GetComponent <Satellite>(); Satellite focused_satellite = FocusedObject.GetComponent <Satellite>(); Satellite last_focused_satellite = last_focused_object.GetComponent <Satellite>(); if (focused_satellite == null || last_focused_satellite == null || root_satellite == null) { throw new System.NotImplementedException(); } Vector3 compressed_position = GetCompressedPosition(focused_satellite, physical_position); if (TransitionMoment < 1) { compressed_position = compressed_position.Lerped( GetCompressedPosition(last_focused_satellite, physical_position), 1 - TransitionMoment); } compressed_position = compressed_position.Lerped( GetCompressedPosition(root_satellite, physical_position), 0.5f); return(ObjectsContainer.TransformPoint(compressed_position * PixelRadius)); }
/// <summary> /// Throws OnDoubleTap. /// </summary> private void OnDoubleTap() { Debug.Log("DoubleTap" + FocusedObject.name); if (FocusedObject != null) { FocusedObject.SendMessage("OnDoubleTap", SendMessageOptions.DontRequireReceiver); } }
private void OnTap() { if (!blockTapEvents && FocusedObject != null) { tapEvent = true; FocusedObject.SendMessage("OnSelect"); } }
private void OnRecognitionStarted() { if (FocusedObject != null) { hasRecognitionStarted = true; FocusedObject.SendMessage("OnPressed", SendMessageOptions.DontRequireReceiver); } }
private void OnRecognitionEndeded() { if (FocusedObject != null && hasRecognitionStarted) { FocusedObject.SendMessage("OnReleased", SendMessageOptions.DontRequireReceiver); } hasRecognitionStarted = false; }
private void Recognizer_ManipulationUpdatedEvent(InteractionSourceKind source, Vector3 position, Ray ray) { if (FocusedObject != null) { IsManipulating = true; FocusedObject.SendMessageUpwards("PerformManipulationUpdate", position); } }
private void ManipulationRecognizer_ManipulationCanceledEvent(InteractionSourceKind source, Vector3 position, Ray ray) { IsManipulating = false; if (FocusedObject != null) { Transform widget_placholder_temp = FocusedObject.transform.parent.parent.transform; Transform widget_snap_transform = widget_manager.snapTransform(widget_placholder_temp); FocusedObject.SendMessageUpwards("PerformManipulationCanceled", widget_snap_transform); } }
private void OnTap() { if (FocusedObject != null) { Debug.Log("foo"); FocusedObject.SendMessage("OnSelect"); GetComponent <NavMeshAgent>().SetDestination(GazeManager.Instance.Position); } }
/// <summary> /// Throws OnSelect. /// </summary> private void OnTap() { if (FocusedObject != null) { //Added this to play nice with selectable var eventData = new BaseEventData(EventSystem.current); FocusedObject.SendMessage("OnSelect", eventData, SendMessageOptions.DontRequireReceiver); FocusedObject.SendMessage("OnPointerClick", new PointerEventData(EventSystem.current), SendMessageOptions.DontRequireReceiver); } }
private void Recognizer_ManipulationUpdatedEvent(InteractionSourceKind source, Vector3 cumulativeDelta, Ray headRay) { if (FocusedObject != null && HasSelection) { var selectable = FocusedObject.GetComponent <Selectable>(); if (selectable != null) { selectable.OnManipulate(cumulativeDelta); } } }
private void CursorUpdate() { oldFocusedObject = FocusedObject; switch (priority) { case CursorFocusPriority.Hand: if (HandManager.instance.HandDetected) { HandUpdate(); } else { GazeUpdate(); } break; case CursorFocusPriority.Gaze: GazeUpdate(); break; default: break; } // Message sending should be suppressed while dragging if (!Dragging) { // Send Messages if (FocusedObject != oldFocusedObject) { if (FocusedObject != null) { FocusedObject.SendMessage("OnFocusEnter", this, SendMessageOptions.DontRequireReceiver); HUDLogController.QuickMessage("Focus Enter " + FocusedObject.name); } if (oldFocusedObject != null) { oldFocusedObject.SendMessage("OnFocusExit", this, SendMessageOptions.DontRequireReceiver); HUDLogController.QuickMessage("Focus Exit " + oldFocusedObject.name); } } else { if (FocusedObject != null) { FocusedObject.SendMessage("OnFocusOver", this, SendMessageOptions.DontRequireReceiver); } } } else { DraggedObject.transform.position = mesh.transform.position; } }
/// <summary> /// Calculates the Raycast hit position and normal. /// </summary> private void UpdateRaycast() { // Get the raycast hit information from Unity's physics system. RaycastHit hitInfo; if (GazeStabilization != null) { Hit = Physics.Raycast(GazeStabilization.StableHeadRay, out hitInfo, MaxGazeDistance, RaycastLayerMask); } else { Hit = Physics.Raycast(gazeOrigin, gazeDirection, out hitInfo, MaxGazeDistance, RaycastLayerMask); } GameObject oldFocusedObject = FocusedObject; // Update the HitInfo property so other classes can use this hit information. HitInfo = hitInfo; if (Hit) { // If the raycast hits a hologram, set the position and normal to match the intersection point. Position = hitInfo.point; Normal = hitInfo.normal; lastHitDistance = hitInfo.distance; FocusedObject = hitInfo.collider.gameObject; } else { // If the raycast does not hit a hologram, default the position to last hit distance in front of the user, // and the normal to face the user. Position = gazeOrigin + (gazeDirection * lastHitDistance); Normal = -gazeDirection; FocusedObject = null; } // Check if the currently hit object has changed if (oldFocusedObject != FocusedObject) { if (oldFocusedObject != null) { oldFocusedObject.SendMessage("OnGazeLeave", SendMessageOptions.DontRequireReceiver); } if (FocusedObject != null) { FocusedObject.SendMessage("OnGazeEnter", SendMessageOptions.DontRequireReceiver); } } }
// Use this for initialization void Start() { Instance = this; recognizer = new GestureRecognizer(); recognizer.TappedEvent += (source, tapCount, ray) => { if (FocusedObject != null) { FocusedObject.SendMessageUpwards("OnSelect"); } }; recognizer.StartCapturingGestures(); }
private void OnTap() { if (SceneManager.Instance.currentSceneState.Value.SceneModeType == SceneModeType.Placement) { SceneManager.Instance.SendMessage("OnPlaced", SendMessageOptions.DontRequireReceiver); } if (SceneManager.Instance.CurrentInteractiveObject() != null) { SceneManager.Instance.CurrentInteractiveObject().GetComponent <SnapToPosition>().SendMessage("OnSelect"); } else if (FocusedObject != null) { FocusedObject.SendMessage("OnSelect", SendMessageOptions.DontRequireReceiver); } }
/// <summary> /// Throws OnSelect. /// </summary> private void OnTap() { SpawnManager.Instance.Tap(); if (FocusedObject != null) { FocusedObject.SendMessage("OnSelect", SendMessageOptions.DontRequireReceiver); if (FocusedObject.GetComponent <ModalObject>() == null) { SelectionManager.Instance.DeselectAll(); } } else { SelectionManager.Instance.DeselectAll(); } }
/// <summary> /// Updates the gaze focus according to the latest gaze data. /// </summary> public void UpdateGazeFocus() { if (!IsInitialized) { return; } IEnumerable <global::Tobii.Framework.GazePoint> lastGazePoints; if (!TryGetLastGazePoints(out lastGazePoints)) { FocusedObject = Scorer.GetFocusedObject(); return; } FocusedObject = Scorer.GetFocusedObject(lastGazePoints, Camera); }
private void OnTap(InteractionSourceKind source, int tapCount, Ray ray) { if (!begin) { return; } // 需要给目标物体发个指令 if (FocusedObject != null) { FocusedObject.SendMessage("OnTapOnObject", SendMessageOptions.DontRequireReceiver); } if (cbTap != null) { cbTap(tapCount); } }
// Use this for initialization void Awake() { Instance = this; if (ObjectMenu == null) { ObjectMenu = GameObject.FindGameObjectWithTag("ObjectMenu"); } // Set up a GestureRecognizer to detect Select gestures. recognizer = new GestureRecognizer(); recognizer.TappedEvent += (source, tapCount, ray) => { // Send an OnSelect message to the focused object and its ancestors. if (FocusedObject != null) { FocusedObject.SendMessageUpwards("OnSelect"); } else { if (!IsShowingMenu) { if (ObjectMenu != null) { ObjectMenu.transform.position = Camera.main.transform.forward * 15; ObjectMenu.transform.rotation = Camera.main.transform.rotation; ObjectMenu.GetComponent <Canvas>().enabled = true; } IsShowingMenu = true; } else { if (ObjectMenu != null) { ObjectMenu.GetComponent <Canvas>().enabled = false; } IsShowingMenu = false; } } }; recognizer.StartCapturingGestures(); }
// Use this for initialization void Start() { Instance = this; // Set up a GestureRecognizer to detect Select gestures. recognizer = new GestureRecognizer(); // Resigister a SendMessageUpwards with the gesture recognizer. // This will be called whenever a Tapped gesture is detected by the HoloLens recognizer.Tapped += (args) => { // Send an OnSelect message to the focused object and its ancestors. if (FocusedObject != null) { FocusedObject.SendMessageUpwards("OnSelect", SendMessageOptions.DontRequireReceiver); } }; recognizer.StartCapturingGestures(); }
//private void NavigationRecognizer_TappedEvent(InteractionSourceKind source, int tapCount, Ray headRay) //{ // throw new System.NotImplementedException(); //} private void Recognizer_TappedEvent(InteractionSourceKind source, int tapCount, Ray headRay) { //throw new System.NotImplementedException(); if (FocusedObject != null) { if (FocusedObject.tag == "MyButton") { FocusedObject.SendMessageUpwards("Toggle", FocusedObject); Debug.Log("object is " + FocusedObject); } else { //SendMessageUpwards sends to both ancesters and the children Debug.Log("~~~~~~~Focusd Object is " + FocusedObject.gameObject.name); FocusedObject.SendMessageUpwards("OnSelect"); } } }