コード例 #1
0
        private static Vector2 GetInterpolatedPosition(FakePress fakePress)
        {
            var now       = Time.time;
            var deltaTime = Math.Min(1, (now - fakePress.startTime) / (fakePress.endTime - fakePress.startTime));

            return(fakePress.startPos + deltaTime * (fakePress.endPos - fakePress.startPos));
        }
コード例 #2
0
        // Internal methods used for playback of recorded data
        internal static void FakeButtonDown(int button, Vector2 downPos, Vector2 upPos, float duration = 1f)
        {
            var fakeMousePress = new FakePress
            {
                startTime = Time.time,
                endTime   = Time.time + duration,
                startPos  = downPos,
                endPos    = upPos
            };

            fakeMousePresses[button] = fakeMousePress;
            fakeMouseUpEvents.Remove(button);
            fakeMouseDownEvents.Add(button);
        }
コード例 #3
0
        internal static void FakeTouch(Touch touch, Vector2 releasePos, float duration)
        {
            var press = new FakePress
            {
                startTime = Time.time,
                endTime   = Time.time + duration,
                startPos  = touch.position,
                endPos    = releasePos
            };

            fakeTouchPresses[touch.fingerId] = press;

            for (int i = 0; i < fakeTouches.Count; i++)
            {
                if (fakeTouches[i].fingerId == touch.fingerId)
                {
                    fakeTouches[i] = touch;
                    return;
                }
            }
            fakeTouches.Add(touch);
        }