コード例 #1
0
        public static Touch[] UpdateAndGet()
        {
            UnityTouchCreator touch = null;

            var mousePos3D = Input.mousePosition;
            var mousePos   = new Vector2(mousePos3D.x, mousePos3D.y);
            var downNow    = Input.GetMouseButton(0);

            if (!s_downLastFrame && downNow)                                    // 안눌렸다가 새로 눌림
            {
                touch       = new UnityTouchCreator();
                touch.phase = TouchPhase.Began;
            }
            else if (s_downLastFrame && downNow)                                // 계속 눌린 경우
            {
                touch       = new UnityTouchCreator();
                touch.phase = (mousePos == s_lastPosition)? TouchPhase.Stationary : TouchPhase.Moved;
            }
            else if (s_downLastFrame && !downNow)
            {                                                                                                   // 눌렀다가 뗀 경우
                touch       = new UnityTouchCreator();
                touch.phase = TouchPhase.Ended;
            }

            s_downLastFrame = downNow;                                                  // 눌렸는지 여부 보관

            if (touch != null)                                                          // touch 오브젝트를 어쨌거나 생성하는 경우
            {
                touch.fingerId      = 1;
                touch.position      = mousePos;
                touch.deltaPosition = mousePos - s_lastPosition;

                s_lastPosition = mousePos;                                              // 마우스 좌표 보관

                return(new Touch[] { touch.Create() });
            }
            else
            {                                                                                                   // Touch 오브젝트를 생성하지 않는 경우, 빈 배열 리턴
                return(new Touch[0]);
            }
        }
コード例 #2
0
        public static Touch[] UpdateAndGet()
        {
            UnityTouchCreator touch	= null;

            var mousePos3D	= Input.mousePosition;
            var mousePos	= new Vector2(mousePos3D.x, mousePos3D.y);
            var downNow		= Input.GetMouseButton(0);

            if (!s_downLastFrame && downNow)			// 안눌렸다가 새로 눌림
            {
                touch			= new UnityTouchCreator();
                touch.phase		= TouchPhase.Began;
            }
            else if(s_downLastFrame && downNow)			// 계속 눌린 경우
            {
                touch			= new UnityTouchCreator();
                touch.phase		= (mousePos == s_lastPosition)? TouchPhase.Stationary : TouchPhase.Moved;
            }
            else if(s_downLastFrame && !downNow)
            {											// 눌렀다가 뗀 경우
                touch			= new UnityTouchCreator();
                touch.phase		= TouchPhase.Ended;
            }

            s_downLastFrame		= downNow;				// 눌렸는지 여부 보관

            if (touch != null)							// touch 오브젝트를 어쨌거나 생성하는 경우
            {
                touch.fingerId	= 1;
                touch.position	= mousePos;
                touch.deltaPosition	= mousePos - s_lastPosition;

                s_lastPosition	= mousePos;				// 마우스 좌표 보관

                return new Touch[] { touch.Create() };
            }
            else
            {											// Touch 오브젝트를 생성하지 않는 경우, 빈 배열 리턴
                return new Touch[0];
            }
        }