public void Touch(TouchPhase phase, int id, int x, int y)
    {
        string log = "Touch " + phase.ToString() + " of finger " + id + " at " + x + " : " + y;

        Debug.Log(log);
        SendPack(x, y, (int)phase + 20, id);
        receiveToBytes();
    }
Esempio n. 2
0
        void Update()
        {
#if UNITY_TVOS
            if (!gameStarted)
            {
                return;
            }

            float h = Input.GetAxis("Horizontal");

            if (h < 0)
            {
                _OnTouchLeft();
            }
            else if (h > 0)
            {
                _OnTouchRight();
            }

            int nbTouches = Input.touchCount;

            if (nbTouches > 0)
            {
                Touch touch = Input.GetTouch(0);

                TouchPhase phase = touch.phase;

                print("" + phase.ToString() + " position = " + touch.position);
            }
#endif

#if (UNITY_ANDROID || UNITY_IOS || UNITY_TVOS)
            int nbTouches = Input.touchCount;

            if (nbTouches > 0)
            {
                Touch touch = Input.GetTouch(0);

                TouchPhase phase = touch.phase;

                if (phase == TouchPhase.Began)
                {
                    if (touch.position.x < Screen.width / 2f)
                    {
                        _OnTouchLeft();
                    }
                    else
                    {
                        _OnTouchRight();
                    }
                }
            }
#endif

#if (!UNITY_ANDROID && !UNITY_IOS && !UNITY_TVOS) || UNITY_EDITOR
            if (Input.GetKeyDown(KeyCode.LeftArrow))
            {
                _OnTouchLeft();
            }
            if (Input.GetKeyDown(KeyCode.RightArrow))
            {
                _OnTouchRight();
            }
#endif
        }
Esempio n. 3
0
 public override string ToString()
 {
     return("Input in id \"" + fingerId + "\". Position: " + position.ToString() + ". Phase: " + phase.ToString());
 }