コード例 #1
0
    public void TouchBegan(int fingerId, Vector2 screenPosition)
    {
        if (!touchInfo.ContainsKey(fingerId))
        {
            var fingerInfo = new List <TouchInfo.FingerPositionInfo>();
            fingerInfo.Add(new TouchInfo.FingerPositionInfo(screenPosition, Time.time));
            var currentTouchInfo = new TouchInfo()
            {
                fingerPositionsInfo = fingerInfo
            };
            touchInfo.Add(fingerId, currentTouchInfo);

            OnTouchBegan?.Invoke(fingerId, currentTouchInfo);
        }
    }
コード例 #2
0
        private void Mobile_Update()
        {
            PrevTouchCount = Input.touchCount;

            MainInputPresent = PrevTouchCount > 0;

            for (int _touchIndex = 0; _touchIndex < PrevTouchCount; _touchIndex++)
            {
                Touch _touch = Input.touches[_touchIndex];

                if (_touch.phase == TouchPhase.Began)
                {
                    OnTouchBegan?.Invoke(_touch);
                }
                if (_touch.phase == TouchPhase.Ended)
                {
                    OnTouchEnded?.Invoke(_touch);
                }
            }
        }
コード例 #3
0
    // Update is called once per frame
    void Update()
    {
        if (Input.touchCount == 1 && !DragCameraZoom.b_IsTouch2)
        {
            touch = Input.GetTouch(0);

            if (touch.phase == TouchPhase.Began)
            {
                OnTouchBegan?.Invoke();
            }
            if (touch.phase == TouchPhase.Moved)
            {
                OnTouchMoved?.Invoke();
            }
            else if (touch.phase == TouchPhase.Ended)
            {
                OnTouchEnded?.Invoke();
            }
        }
    }
コード例 #4
0
        /// <summary>
        /// 更新中の場合
        /// </summary>
        private void Update()
        {
            // UIを選択した場合ここで処理終了
            if (IsSelectedUI())
            {
                return;
            }

#if UNITY_EDITOR // UNITYエディタの場合
            if (Input.GetMouseButtonDown(0))
            {
                OnTouchBegan?.Invoke();
            }
            else if (Input.GetMouseButton(0))
            {
                OnTouchMoved?.Invoke();
            }
            else if (Input.GetMouseButtonUp(0))
            {
                OnTouchEnded?.Invoke();
            }
#else // 実機の場合
            if (Input.touchCount > 0)
            {
                // 0番目のタッチ取得
                var touch = Input.GetTouch(0);

                switch (touch.phase)
                {
                case TouchPhase.Began:
                {
                    OnTouchBegan?.Invoke();
                }
                break;

                case TouchPhase.Moved:
                {
                    OnTouchMoved?.Invoke();
                }
                break;

                case TouchPhase.Ended:
                {
                    OnTouchEnded?.Invoke();
                }
                break;

                case TouchPhase.Stationary:
                {
                    OnTouchStationary?.Invoke();
                }
                break;

                case TouchPhase.Canceled:
                {
                    OnTouchCanceled?.Invoke();
                }
                break;
                }
            }
#endif
        }