public void Update()
        {
            var touching = BaseInput.IsTouching(true);

            if (touching)
            {
                var touch0Position = BaseInput.GetTouchPosition(0).y;
                var touch1Position = BaseInput.GetTouchPosition(1).y;
                var position       = (touch0Position + touch1Position) * 0.5f;

                if (!Panning)
                {
                    if (!WasTouching)
                    {
                        LastPosition = position;
                    }

                    var delta = Mathf.Abs(position - LastPosition);

                    if (!Rotating && delta >= Threshold)
                    {
                        LastPosition = position;
                        Panning      = true;
                    }
                }
                if (Panning)
                {
                    var delta = position - LastPosition;
                    OnDragEvent.Invoke(Vector3.up * (delta * Ratio));

                    LastPosition = position;
                }
            }

            if (!touching && Panning)
            {
                Panning = false;
                OnReleaseEvent.Invoke();
            }

            WasTouching = touching;
        }
Exemple #2
0
        public void Update()
        {
            var touching = BaseInput.IsTouching(true);

            if (touching)
            {
                var touch0Position = BaseInput.GetTouchPosition(0);
                var touch1Position = BaseInput.GetTouchPosition(1);
                var angle          = CalculateAngle(touch0Position, touch1Position);

                if (!Rotating)
                {
                    if (!WasTouching)
                    {
                        LastAngle = angle;
                    }

                    var delta = angle - LastAngle;
                    if (!Panning && Mathf.Abs(delta) >= Threshold)
                    {
                        LastAngle = angle;
                        Rotating  = true;
                    }
                }
                if (Rotating)
                {
                    var delta = angle - LastAngle;
                    OnRotationEvent.Invoke(delta);

                    LastAngle = angle;
                }
            }

            if (!touching && Rotating)
            {
                Rotating = false;
                OnReleaseEvent.Invoke();
            }

            WasTouching = touching;
        }
Exemple #3
0
        private void Update()
        {
            if (!Dragging || Selected == null)
            {
                return;
            }

            if (Raycast(BaseInput.GetTouchPosition(), out var planePosition))
            {
                var delta = planePosition - LastPosition;

                if (Mathf.Approximately(delta.x, 0) && Mathf.Approximately(delta.y, 0) && Mathf.Approximately(delta.z, 0))
                {
                    return;
                }

                OnDragEvent.Invoke(delta);

                LastPosition = planePosition;
            }
        }
Exemple #4
0
        public void OnSelection(Element element)
        {
            Selected = element;

            OnTap(BaseInput.GetTouchPosition());
        }