Ejemplo n.º 1
0
        private void OnReleased(PointerInput input, double time)
        {
            if (!activeGestures.TryGetValue(input.InputId, out var existingGesture))
            {
                // Probably caught by UI, or the input was otherwise lost
                return;
            }

            activeGestures.Remove(input.InputId);
            existingGesture.SubmitPoint(input.Position, time);

            if (IsValidSwipe(ref existingGesture))
            {
                var swipeInput = new SwipeInput(existingGesture);
                Swiped?.Invoke(swipeInput);
                onSwiped?.Invoke(swipeInput);
            }

            if (IsValidTap(ref existingGesture))
            {
                var tapInput = new TapInput(existingGesture);
                Tapped?.Invoke(tapInput);
                onTapped?.Invoke(tapInput);
            }

#if UNITY_EDITOR
            DebugInfo(existingGesture);
#endif
        }
Ejemplo n.º 2
0
        private void OnPressed(PointerInput input, double time)
        {
            Debug.Assert(!activeGestures.ContainsKey(input.InputId));

            var newGesture = new ActiveGesture(input.InputId, input.Position, time);

            activeGestures.Add(input.InputId, newGesture);

#if UNITY_EDITOR
            DebugInfo(newGesture);
#endif
            var swipeInput = new SwipeInput(newGesture);
            Pressed?.Invoke(swipeInput);
            onPressed?.Invoke(swipeInput);
        }
Ejemplo n.º 3
0
        private void OnDragged(PointerInput input, double time)
        {
            if (!activeGestures.TryGetValue(input.InputId, out var existingGesture))
            {
                // Probably caught by UI, or the input was otherwise lost
                return;
            }

            existingGesture.SubmitPoint(input.Position, time);

            if (IsValidSwipe(ref existingGesture))
            {
                var swipeInput = new SwipeInput(existingGesture);
                PotentiallySwiped?.Invoke(swipeInput);
                onPotentiallySwiped?.Invoke(swipeInput);
            }

#if UNITY_EDITOR
            DebugInfo(existingGesture);
#endif
        }