private void HandlePointerEventRaised(PointerArgs args)
        {
            switch (args.PointerEvent)
            {
            case PointerEvent.Hover:
                _hover = true;
                UpdateMaterialColor();
                break;

            case PointerEvent.Select:
                _select = true;
                UpdateMaterialColor();
                break;

            case PointerEvent.Move:
                break;

            case PointerEvent.Unselect:
                _select = false;
                UpdateMaterialColor();
                break;

            case PointerEvent.Unhover:
                _hover = false;
                UpdateMaterialColor();
                break;
            }
        }
Example #2
0
        public override void ProcessPointerEvent(PointerArgs args)
        {
            switch (args.PointerEvent)
            {
            case PointerEvent.Select:
                EndTransform();
                break;

            case PointerEvent.Unselect:
                EndTransform();
                break;

            case PointerEvent.Cancel:
                EndTransform();
                break;
            }

            base.ProcessPointerEvent(args);

            switch (args.PointerEvent)
            {
            case PointerEvent.Select:
                BeginTransform();
                break;

            case PointerEvent.Unselect:
                BeginTransform();
                break;

            case PointerEvent.Move:
                UpdateTransform();
                break;
            }
        }
Example #3
0
        private void HandlePointerEventRaised(PointerArgs args)
        {
            switch (args.PointerEvent)
            {
            case PointerEvent.Hover:
                _whenHover.Invoke();
                break;

            case PointerEvent.Unhover:
                _whenUnhover.Invoke();
                break;

            case PointerEvent.Select:
                _whenSelect.Invoke();
                break;

            case PointerEvent.Unselect:
                _whenUnselect.Invoke();
                break;

            case PointerEvent.Move:
                _whenMove.Invoke();
                break;

            case PointerEvent.Cancel:
                _whenCancel.Invoke();
                break;
            }
        }
Example #4
0
        protected override void HandlePointerEventRaised(PointerArgs args)
        {
            base.HandlePointerEventRaised(args);

            if (SelectedInteractable == null)
            {
                return;
            }

            if (args.PointerEvent == PointerEvent.Select ||
                args.PointerEvent == PointerEvent.Unselect ||
                args.PointerEvent == PointerEvent.Cancel)
            {
                Pose target = _grabTarget.GetPose();
                if (SelectedInteractable.ResetGrabOnGrabsUpdated)
                {
                    Pose source = _interactable.GetGrabSourceForTarget(target);
                    _tween.StopAndSetPose(source);
                    SelectedInteractable.PointableElement.ProcessPointerEvent(
                        new PointerArgs(Identifier, PointerEvent.Move, _tween.Pose));
                    _tween.MoveTo(target);
                }
                else
                {
                    _tween.StopAndSetPose(target);
                    SelectedInteractable.PointableElement.ProcessPointerEvent(
                        new PointerArgs(Identifier, PointerEvent.Move, target));
                    _tween.MoveTo(target);
                }
            }
        }
        private void HandlePointerEventRaised(PointerArgs args)
        {
            switch (args.PointerEvent)
            {
            case PointerEvent.Hover:
                _points.Add(args.Identifier,
                            new PointData()
                {
                    Pose = args.Pose, Selecting = false
                });
                break;

            case PointerEvent.Select:
                _points[args.Identifier].Selecting = true;
                break;

            case PointerEvent.Move:
                _points[args.Identifier].Pose = args.Pose;
                break;

            case PointerEvent.Unselect:
                _points[args.Identifier].Selecting = false;
                break;

            case PointerEvent.Unhover:
            case PointerEvent.Cancel:
                _points.Remove(args.Identifier);
                break;
            }
        }
Example #6
0
        public virtual void ProcessPointerEvent(PointerArgs args)
        {
            switch (args.PointerEvent)
            {
            case PointerEvent.Hover:
                Hover(args);
                break;

            case PointerEvent.Unhover:
                Unhover(args);
                break;

            case PointerEvent.Move:
                Move(args);
                break;

            case PointerEvent.Select:
                Select(args);
                break;

            case PointerEvent.Unselect:
                Unselect(args);
                break;

            case PointerEvent.Cancel:
                Cancel(args);
                break;
            }
        }
Example #7
0
 private void HandlePointerEventRaised(PointerArgs args)
 {
     if (args.PointerEvent == PointerEvent.Cancel)
     {
         ProcessPointerEvent(args);
     }
 }
Example #8
0
 protected virtual void PointableElementUpdated(PointerArgs args)
 {
     if (ForwardElement != null)
     {
         ForwardElement.ProcessPointerEvent(args);
     }
     WhenPointerEventRaised.Invoke(args);
 }
Example #9
0
        public override void ProcessPointerEvent(PointerArgs args)
        {
            Vector3 transformPosition =
                _canvasRenderTextureMesh.ImposterToCanvasTransformPoint(args.Pose.position);
            Pose transformedPose = new Pose(transformPosition, args.Pose.rotation);

            base.ProcessPointerEvent(new PointerArgs(args.Identifier, args.PointerEvent, transformedPose));
        }
Example #10
0
 protected virtual void HandlePointerEventRaised(PointerArgs args)
 {
     if (args.Identifier == Identifier &&
         args.PointerEvent == PointerEvent.Cancel &&
         Interactable != null)
     {
         Interactable.RemoveInteractorById(Identifier);
         Interactable.PointableElement.WhenPointerEventRaised -=
             HandlePointerEventRaised;
     }
 }
Example #11
0
        private void Unselect(PointerArgs args)
        {
            int index = _selectingPointIds.IndexOf(args.Identifier);

            if (index == -1)
            {
                return;
            }

            _selectingPointIds.RemoveAt(index);
            _selectingPoints.RemoveAt(index);

            PointableElementUpdated(args);
        }
Example #12
0
        private void Hover(PointerArgs args)
        {
            if (_addNewPointsToFront)
            {
                _pointIds.Insert(0, args.Identifier);
                _points.Insert(0, args.Pose);
            }
            else
            {
                _pointIds.Add(args.Identifier);
                _points.Add(args.Pose);
            }

            PointableElementUpdated(args);
        }
        private void HandlePointerEvent(Canvas canvas, PointerArgs args)
        {
            Pointer pointer;

            switch (args.PointerEvent)
            {
            case PointerEvent.Hover:
                pointer = new Pointer(canvas);
                pointer.PointerEventData = new PointerEventData(eventSystem);
                pointer.SetPosition(args.Pose.position);
                _pointerMap.Add(args.Identifier, pointer);
                break;

            case PointerEvent.Unhover:
                pointer = _pointerMap[args.Identifier];
                _pointerMap.Remove(args.Identifier);
                pointer.MarkForDeletion();
                _pointersForDeletion.Add(pointer);
                break;

            case PointerEvent.Select:
                pointer = _pointerMap[args.Identifier];
                pointer.SetPosition(args.Pose.position);
                pointer.Press();
                break;

            case PointerEvent.Unselect:
                pointer = _pointerMap[args.Identifier];
                pointer.SetPosition(args.Pose.position);
                pointer.Release();
                break;

            case PointerEvent.Move:
                pointer = _pointerMap[args.Identifier];
                pointer.SetPosition(args.Pose.position);
                break;

            case PointerEvent.Cancel:
                pointer = _pointerMap[args.Identifier];
                _pointerMap.Remove(args.Identifier);
                ClearPointerSelection(pointer.PointerEventData);
                pointer.MarkForDeletion();
                _pointersForDeletion.Add(pointer);
                break;
            }
        }
Example #14
0
        private void Move(PointerArgs args)
        {
            int index = _pointIds.IndexOf(args.Identifier);

            if (index == -1)
            {
                return;
            }
            _points[index] = args.Pose;

            index = _selectingPointIds.IndexOf(args.Identifier);
            if (index != -1)
            {
                _selectingPoints[index] = args.Pose;
            }

            PointableElementUpdated(args);
        }
Example #15
0
        private void Select(PointerArgs args)
        {
            if (_selectingPoints.Count == 1 && _transferOnSecondSelection)
            {
                Cancel(new PointerArgs(_selectingPointIds[0], PointerEvent.Cancel, _selectingPoints[0]));
            }

            if (_addNewPointsToFront)
            {
                _selectingPointIds.Insert(0, args.Identifier);
                _selectingPoints.Insert(0, args.Pose);
            }
            else
            {
                _selectingPointIds.Add(args.Identifier);
                _selectingPoints.Add(args.Pose);
            }

            PointableElementUpdated(args);
        }
Example #16
0
        private void HandlePointerEventRaised(PointerArgs args)
        {
            switch (args.PointerEvent)
            {
            case PointerEvent.Select:
                if (_grabbable.SelectingPointsCount == 1 && !_isBeingTransformed)
                {
                    DisablePhysics();
                }

                break;

            case PointerEvent.Unselect:
                if (_grabbable.SelectingPointsCount == 0)
                {
                    ReenablePhysics();
                }

                break;
            }
        }
Example #17
0
        private void Cancel(PointerArgs args)
        {
            int index = _selectingPointIds.IndexOf(args.Identifier);

            if (index != -1)
            {
                _selectingPointIds.RemoveAt(index);
                _selectingPoints.RemoveAt(index);
            }

            index = _pointIds.IndexOf(args.Identifier);
            if (index != -1)
            {
                _pointIds.RemoveAt(index);
                _points.RemoveAt(index);
            }
            else
            {
                return;
            }

            PointableElementUpdated(args);
        }
Example #18
0
 public void PublishPointerEvent(PointerArgs args)
 {
     WhenPointerEventRaised(args);
 }