private void OnPointerDown(MixedRealityPointerEventData eventData)
        {
            if (currentPointer == null && !eventData.used)
            {
                GameObject grabbedHandle          = eventData.Pointer.Result.CurrentPointerTarget;
                Transform  grabbedHandleTransform = grabbedHandle.transform;
                currentHandleType = GetHandleType(grabbedHandleTransform);
                if (currentHandleType != HandleType.None)
                {
                    currentPointer             = eventData.Pointer;
                    initialGrabPoint           = currentPointer.Result.Details.Point;
                    currentGrabPoint           = initialGrabPoint;
                    initialScaleOnGrabStart    = Target.transform.localScale;
                    initialPositionOnGrabStart = Target.transform.position;
                    grabPointInPointer         = Quaternion.Inverse(eventData.Pointer.Rotation) * (initialGrabPoint - currentPointer.Position);

                    // todo: move this out?
                    SetHighlighted(grabbedHandleTransform);

                    if (currentHandleType == HandleType.Scale)
                    {
                        // Will use this to scale the target relative to the opposite corner
                        oppositeCorner = rigRoot.transform.TransformPoint(-grabbedHandle.transform.localPosition);
                        diagonalDir    = (grabbedHandle.transform.position - oppositeCorner).normalized;

                        ScaleStarted?.Invoke();

                        if (debugText != null)
                        {
                            debugText.text = "OnPointerDown:ScaleStarted";
                        }
                    }
                    else if (currentHandleType == HandleType.Rotation)
                    {
                        currentRotationAxis = GetRotationAxis(grabbedHandleTransform);

                        RotateStarted?.Invoke();

                        if (debugText != null)
                        {
                            debugText.text = "OnPointerDown:RotateStarted";
                        }
                    }

                    eventData.Use();
                }
            }

            if (currentPointer != null)
            {
                // Always mark the pointer data as used to prevent any other behavior to handle pointer events
                // as long as bounds control manipulation is active.
                // This is due to us reacting to both "Select" and "Grip" events.
                eventData.Use();
            }
        }
Example #2
0
    public void OnPointerClicked(MixedRealityPointerEventData eventData)
    {
        if (_pointer == eventData.Pointer &&
            CoreServices.InputSystem.FocusProvider.TryGetFocusDetails(_pointer, out var focusDetails) &&
            focusDetails.Object == gameObject)
        {
            if (!_isInteracting)
            {
                // Check for a double tap.
                if ((Time.time - _lastClickTime) < DoubleTapThresholdInSeconds)
                {
                    var targetLatLon = _targetPointInMercator.ToLatLon();

                    var newZoomLevel = MapRenderer.ZoomLevel + 1.0f;
                    newZoomLevel = Mathf.Max(MapRenderer.MinimumZoomLevel, Mathf.Min(MapRenderer.MaximumZoomLevel, newZoomLevel));
                    MapRenderer.SetMapScene(new MapSceneOfLocationAndZoomLevel(targetLatLon, newZoomLevel), MapSceneAnimationKind.Linear, 150.0f);

                    MapInteractionController.OnDoubleTap?.Invoke(new LatLonAlt(targetLatLon, _targetAltitudeInMeters));
                    _lastClickTime = float.MinValue;
                }
                else
                {
                    _lastClickTime = Time.time;
                }
            }
            else
            {
                _lastClickTime = float.MinValue;
            }

            eventData.Use();
        }
    }
        void IMixedRealityPointerHandler.OnPointerDown(MixedRealityPointerEventData eventData)
        {
            Debug.Log(eventData.MixedRealityInputAction.Description);
            if (!isDraggingEnabled || isDragging || eventData.MixedRealityInputAction != dragAction)
            {
                // If we're already handling drag input or we're not grabbing, don't start a new drag operation.
                return;
            }

            eventData.Use(); // Mark the event as used, so it doesn't fall through to other handlers.

            currentInputSource = eventData.InputSource;
            currentPointer     = eventData.Pointer;

            if (!IsPointerRayHitSelf())
            {
                return;
            }

            FocusDetails focusDetails;
            Vector3      initialDraggingPosition = MixedRealityToolkit.InputSystem.FocusProvider.TryGetFocusDetails(currentPointer, out focusDetails)
                    ? focusDetails.Point
                    : hostTransform.position;

            isDraggingWithSourcePose = currentPointer == MixedRealityToolkit.InputSystem.GazeProvider.GazePointer;

            StartDragging(initialDraggingPosition);
        }
Example #4
0
        /// <inheritdoc />
        void IMixedRealityPointerHandler.OnPointerDown(MixedRealityPointerEventData eventData)
        {
            if (isDragging)
            {
                // We're already handling drag input, so we can't start a new drag operation.
                return;
            }

            if (eventData.MixedRealityInputAction != dragAction)
            {
                // If we're not grabbing.
                return;
            }

            eventData.Use(); // Mark the event as used, so it doesn't fall through to other handlers.

            currentInputSource = eventData.InputSource;
            currentPointer     = eventData.Pointer;

            Vector3 initialDraggingPosition = FocusProvider.TryGetFocusDetails(currentPointer, out var focusDetails)
                    ? focusDetails.EndPoint
                    : hostTransform.position;

            StartDragging(initialDraggingPosition);
        }
Example #5
0
        public void OnPointerClicked(MixedRealityPointerEventData eventData)
        {
            if (spawnedObject.activeSelf)
            {
                spawnedObject.SetActive(false);
                hideThisObject.SetActive(true);
            }
            else
            {
                spawnedObject.SetActive(true);

                if (updateSolverTargetToClickSource && solverHandler != null)
                {
                    if (MixedRealityToolkit.InputSystem.TryGetController(eventData.InputSource, out IMixedRealityController controller))
                    {
                        if (controller.ControllerHandedness == Handedness.Right)
                        {
                            solverHandler.TrackedObjectToReference = TrackedObjectType.MotionControllerRight;
                        }
                        else if (controller.ControllerHandedness == Handedness.Left)
                        {
                            solverHandler.TrackedObjectToReference = TrackedObjectType.MotionControllerLeft;
                        }
                    }
                }

                hideThisObject.SetActive(false);
            }

            eventData.Use(); // Mark the event as used, so it doesn't fall through to other handlers.
        }
Example #6
0
        /// <inheritdoc />
        public void OnPointerClicked(MixedRealityPointerEventData eventData)
        {
            if (spawnedObject.activeSelf)
            {
                spawnedObject.SetActive(false);
                hideThisObject.SetActive(true);
            }
            else
            {
                spawnedObject.SetActive(true);

                if (updateSolverTargetToClickSource && !solverHandler.IsNull())
                {
                    if (MixedRealityToolkit.TryGetSystem <IMixedRealityInputSystem>(out var inputSystem) &&
                        inputSystem.TryGetController(eventData.InputSource, out var controller))
                    {
                        switch (controller.ControllerHandedness)
                        {
                        case Handedness.Right:
                            solverHandler.TrackedObjectToReference = TrackedObjectType.RightHandOrController;
                            break;

                        case Handedness.Left:
                            solverHandler.TrackedObjectToReference = TrackedObjectType.LeftHandOrController;
                            break;
                        }
                    }
                }

                hideThisObject.SetActive(false);
            }

            eventData.Use(); // Mark the event as used, so it doesn't fall through to other handlers.
        }
        /// <inheritdoc />
        public void OnPointerUp(MixedRealityPointerEventData eventData)
        {
            uint id = eventData.Pointer.PointerId;

            if (pointerIdToPointerMap.ContainsKey(id))
            {
                if (pointerIdToPointerMap.Count == 1 && rigidBody != null)
                {
                    rigidBody.isKinematic = wasKinematic;

                    if (releaseBehavior.HasFlag(ReleaseBehaviorType.KeepVelocity))
                    {
                        rigidBody.velocity = GetPointersVelocity();
                    }

                    if (releaseBehavior.HasFlag(ReleaseBehaviorType.KeepAngularVelocity))
                    {
                        rigidBody.angularVelocity = GetPointersAngularVelocity();
                    }

                    rigidBody = null;
                }

                pointerIdToPointerMap.Remove(id);
            }

            UpdateStateMachine();
            eventData.Use();
        }
 public void OnPointerDragged(MixedRealityPointerEventData eventData)
 {
     if (_panningPointer == eventData.Pointer)
     {
         eventData.Use();
     }
 }
Example #9
0
 public void OnPointerUp(MixedRealityPointerEventData eventData)
 {
     if (eventData.Pointer == activePointer && !eventData.used)
     {
         activePointer = null;
         eventData.Use();
     }
 }
Example #10
0
 void IMixedRealityPointerHandler.OnPointerUp(MixedRealityPointerEventData eventData)
 {
     if (!_searchAreaControl.SearchAreaLocked && !eventData.used)
     {
         _searchAreaControl.PlaceSearchAreaBoundingBoxInFrontOfUser();
         eventData.Use();
     }
 }
 private void OnPointerUp(MixedRealityPointerEventData eventData)
 {
     if (currentPointer != null && eventData.Pointer == currentPointer)
     {
         DropController();
         eventData.Use();
     }
 }
Example #12
0
 public void OnPointerDragged(MixedRealityPointerEventData eventData)
 {
     if (eventData.Pointer == activePointer && !eventData.used)
     {
         progressBar.SetHandles(activePointer.Position, handleOnPositiveCap);
         eventData.Use();
     }
 }
Example #13
0
    public void OnPointerUp(MixedRealityPointerEventData eventData)
    {
        if (_pointer == eventData.Pointer)
        {
            eventData.Use();
        }

        _pointer = null;
    }
Example #14
0
        /// <inheritdoc />
        void IMixedRealityPointerHandler.OnPointerUp(MixedRealityPointerEventData eventData)
        {
            if (eventData.SourceId == currentInputSource.SourceId)
            {
                eventData.Use(); // Mark the event as used, so it doesn't fall through to other handlers.

                StopDragging();
            }
        }
        public void OnPointerUp(MixedRealityPointerEventData eventData)
        {
            pointerUpCount++;

            if (useEventDataOnReception)
            {
                eventData.Use();
            }
        }
Example #16
0
 public void OnPointerDown(MixedRealityPointerEventData eventData)
 {
     if (activePointer == null && !eventData.used)
     {
         activePointer = eventData.Pointer;
         progressBar.StartResizing(activePointer.Position, handleOnPositiveCap);
         eventData.Use();
     }
 }
        public virtual void OnPointerClicked(MixedRealityPointerEventData eventData)
        {
            pointerClickedCount++;

            if (useEventDataOnReception)
            {
                eventData.Use();
            }
        }
Example #18
0
        public void OnPointerUp(MixedRealityPointerEventData eventData)
        {
            if (eventData.Pointer == activePointer && !eventData.used)
            {
                OnInteractionEnded?.Invoke();
                activePointer = null;

                eventData.Use();
            }
        }
Example #19
0
        public void OnPointerUp(MixedRealityPointerEventData eventData)
        {
            if (eventData.Pointer == ActivePointer && !eventData.used)
            {
                EndInteraction();

                // Mark the pointer data as used to prevent other behaviors from handling input events
                eventData.Use();
            }
        }
Example #20
0
 public void OnPointerDown(MixedRealityPointerEventData eventData)
 {
     if (activePointer == null && !eventData.used)
     {
         activePointer        = eventData.Pointer;
         startPointerPosition = activePointer.Position;
         startSliderPosition  = gameObject.transform.position;
         OnInteractionStarted?.Invoke();
         eventData.Use();
     }
 }
Example #21
0
        public void OnPointerClicked(MixedRealityPointerEventData eventData)
        {
            // let the Input Handlers know what the pointer action is
            if (eventData != null)
            {
                pointerInputAction = eventData.MixedRealityInputAction;
            }

            // check to see if is global or focus - or - if is global, pointer event does not fire twice  - or - input event is not taking these actions already
            if (!CanInteract() || (IsGlobal && (inputTimer != null || GlobalClickOrder[1] == 1)))
            {
                return;
            }

            if (StateManager != null)
            {
                if (eventData != null && ShouldListen(eventData.MixedRealityInputAction))
                {
                    if (GlobalClickOrder[1] == 0)
                    {
                        GlobalClickOrder[0] = 1;
                    }
                    IncreaseDimensionIndex();
                    SendOnClick(eventData.Pointer);
                    SetVisited(true);
                    StartInputTimer(false);
                    eventData.Use();
                }
                else if (eventData == null && (HasFocus || IsGlobal)) // handle brute force
                {
                    if (GlobalClickOrder[1] == 0)
                    {
                        GlobalClickOrder[0] = 1;
                    }
                    IncreaseDimensionIndex();
                    StartGlobalVisual(false);
                    SendOnClick(null);
                    SetVisited(true);
                    StartInputTimer(false);
                }
                else if (eventData == null && HasPhysicalTouch) // handle touch interactions
                {
                    if (GlobalClickOrder[1] == 0)
                    {
                        GlobalClickOrder[0] = 1;
                    }
                    IncreaseDimensionIndex();
                    StartGlobalVisual(false);
                    SendOnClick(null);
                    SetVisited(true);
                    StartInputTimer(false);
                }
            }
        }
Example #22
0
        public void OnPointerDragged(MixedRealityPointerEventData eventData)
        {
            if (eventData.Pointer == activePointer && !eventData.used)
            {
                Vector3 delta = activePointer.Position - pointerStartPosition;
                float   handDelta;
                if (xAxis)
                {
                    handDelta = Vector3.Dot(kanbanBoardController.transform.right, delta);
                }
                else
                {
                    handDelta = Vector3.Dot(kanbanBoardController.transform.up, delta);
                }
                if (!positiveEnd)
                {
                    handDelta *= -1f;
                }
                if (xAxis)
                {
                    float newLength     = startLength + handDelta;
                    float previousWidth = kanbanBoardController.Width;
                    kanbanBoardController.Width = newLength;
                    if (kanbanBoardController.Width != previousWidth) // only move if the width was actually changed (it could be unaffected if min or max size was reached)
                    {
                        Vector3 pivotCorrection = new Vector3(handDelta / 2f, 0, 0);
                        if (positiveEnd)
                        {
                            pivotCorrection *= -1;
                        }
                        kanbanBoardController.transform.localPosition = kanbanBoardColumnStartPosition - kanbanBoardController.transform.localRotation * pivotCorrection;
                    }
                }
                else
                {
                    float newLength      = startLength + handDelta;
                    float previousHeight = kanbanBoardController.Height;
                    kanbanBoardController.Height = newLength;
                    if (kanbanBoardController.Height != previousHeight) // only move if the height was actually changed (it could be unaffected if min or max size was reached)
                    {
                        Vector3 pivotCorrection = new Vector3(0, handDelta / 2f, 0);
                        if (positiveEnd)
                        {
                            pivotCorrection *= -1;
                        }
                        kanbanBoardController.transform.localPosition = kanbanBoardColumnStartPosition - kanbanBoardController.transform.localRotation * pivotCorrection;
                    }
                }

                // mark pointer data as used
                eventData.Use();
            }
        }
        void IMixedRealityPointerHandler.OnPointerUp(MixedRealityPointerEventData eventData)
        {
            if (!isDraggingEnabled || !isDragging || eventData.MixedRealityInputAction != dragAction || eventData.SourceId != currentInputSource?.SourceId)
            {
                // If we're not handling drag input or we're not releasing the right action, don't try to end a drag operation.
                return;
            }

            eventData.Use(); // Mark the event as used, so it doesn't fall through to other handlers.

            StopDragging();
        }
Example #24
0
 public void OnPointerClicked(MixedRealityPointerEventData eventData)
 {
     if (UnityEngine.XR.WSA.HolographicSettings.IsDisplayOpaque == false && NetworkDiscoveryWithAnchors.Instance.isServer)
     {
         UNetAnchorManager.Instance.MakeNewAnchor();
         eventData.Use();
     }
     else
     {
         Debug.Log("Only the server on hololens for now");
     }
 }
Example #25
0
        public void OnPointerDown(MixedRealityPointerEventData eventData)
        {
            if (activePointer == null && !eventData.used)
            {
                activePointer = eventData.Pointer;
                startPosition = activePointer.Position;
                startHeight   = Height;

                // Mark the pointer data as used to prevent other behaviors from handling input events
                eventData.Use();
            }
        }
Example #26
0
        public void OnPointerDragged(MixedRealityPointerEventData eventData)
        {
            if (eventData.Pointer == activePointer && !eventData.used)
            {
                Vector3 delta     = activePointer.Position - startPointerPosition;
                float   handDelta = Vector3.Dot(DirectionVector, delta);

                transform.position = startSliderPosition + handDelta * DirectionVector;
                OnInteractionUpdated?.Invoke();

                eventData.Use();
            }
        }
Example #27
0
        public virtual void OnPointerDragged(MixedRealityPointerEventData eventData)
        {
            if (eventData.Pointer == ActivePointer && !eventData.used)
            {
                var delta     = ActivePointer.Position - StartPointerPosition;
                var handDelta = Vector3.Dot(SliderTrackDirection.normalized, delta);

                SliderValue = Mathf.Clamp(StartSliderValue + handDelta / SliderTrackDirection.magnitude, 0, 1);

                // Mark the pointer data as used to prevent other behaviors from handling input events
                eventData.Use();
            }
        }
Example #28
0
        public void OnPointerDragged(MixedRealityPointerEventData eventData)
        {
            if (eventData.Pointer == activePointer && !eventData.used)
            {
                Vector3 delta     = activePointer.Position - startPosition;
                float   handDelta = Vector3.Dot(Vector3.up, delta);

                Height = startHeight + handDelta / maxMovement;

                // Mark the pointer data as used to prevent other behaviors from handling input events
                eventData.Use();
            }
        }
Example #29
0
        /// <summary>
        /// Pointer down event has fired
        /// </summary>
        /// <param name="eventData"></param>
        public void OnPointerDown(MixedRealityPointerEventData eventData)
        {
            pointerInputAction = eventData.MixedRealityInputAction;
            if (!CanInteract())
            {
                return;
            }

            if (ShouldListen(eventData.MixedRealityInputAction))
            {
                SetPress(true);
                eventData.Use();
            }
        }
Example #30
0
        /// <summary>
        /// pointer up event has fired
        /// </summary>
        /// <param name="eventData"></param>
        public void OnPointerUp(MixedRealityPointerEventData eventData)
        {
            pointerInputAction = eventData.MixedRealityInputAction;
            if ((!CanInteract() && !HasPress))
            {
                return;
            }

            if (ShouldListen(eventData.MixedRealityInputAction))
            {
                SetPress(false);
                eventData.Use();
            }
        }