Ejemplo n.º 1
0
        void HandleTouchUp(TouchInfo info)
        {
            if (info.lastHit == null)
            {
                return;
            }

            if (ColliderTouchUpMapping.ContainsKey(info.lastHit))
            {
                if (ColliderTouchUpMapping[info.lastHit] != null)
                {
                    if (Debug)
                    {
                        GameLog.Debug(info.lastHit.name + " touchUp, click:" + !info.dragStart);
                    }
                    ColliderTouchUpMapping[info.lastHit](!info.dragStart);
                }
            }
        }
Ejemplo n.º 2
0
        TouchInfo HandleTouchDown()
        {
            if (Camera.main == null)
            {
                return(null);
            }

            TouchInfo info = new TouchInfo();

            info.screenPos     = Input.mousePosition;
            info.lastScreenPos = Input.mousePosition;
            info.delta         = Vector3.zero;
            info.totalDelta    = Vector3.zero;
            info.dragStart     = false;
            info.phase         = TouchPhase.Began;
            info.isOnUI        = InputHelper.IsPointerOverGameObject();

            Ray        ray         = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit lastHitInfo = default(RaycastHit);

            if (Physics.Raycast(ray, out lastHitInfo, 1000f))
            {
                if (!info.isOnUI && lastHitInfo.collider != null && ColliderTouchDownMapping.ContainsKey(lastHitInfo.collider))
                {
                    if (ColliderTouchDownMapping[lastHitInfo.collider] != null)
                    {
                        if (Debug)
                        {
                            GameLog.Debug(lastHitInfo.collider.name + " touchDown");
                        }
                        ColliderTouchDownMapping[lastHitInfo.collider]();
                    }

                    info.lastHit = lastHitInfo.collider;
                }
                else
                {
                    info.lastHit = null;
                }
            }

            return(info);
        }
Ejemplo n.º 3
0
 void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         currentTouch = HandleTouchDown();
     }
     else if (Input.GetMouseButton(0))
     {
         if (currentTouch != null)
         {
             HandleTouchStay(currentTouch);
         }
     }
     else if (Input.GetMouseButtonUp(0))
     {
         if (currentTouch != null)
         {
             HandleTouchUp(currentTouch);
         }
     }
 }