Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        int i = 0;

        while (i < Input.touchCount)
        {
            print(i + "id");
            Touch t = Input.GetTouch(i);
            if (t.phase == TouchPhase.Began)
            {
                print("ISbegn");

                touches.Add(new Touchlocation(t.fingerId, t.position, true));
            }
            else if (t.phase == TouchPhase.Ended)
            {
                Touchlocation thistouch = touches.Find(x => x.touchid == t.fingerId);
                touches.RemoveAt(touches.IndexOf(thistouch));
                thistouch.istouchalive = false;
                print("Ended");
            }
            else if (t.phase == TouchPhase.Moved)
            {
                Touchlocation thistouch = touches.Find(x => x.touchid == t.fingerId);
                thistouch.pos          = t.position;
                thistouch.istouchalive = true;
                print("Moved");
            }
            ++i;
        }
    }
Exemple #2
0
    void Handletouches()
    {
        int i = 0;

        while (i < Input.touchCount)
        {
            print(i + "id");
            Touch t = Input.GetTouch(i);
            if (t.phase == TouchPhase.Began)
            {
                print("ISbegn");


                touches.Add(new Touchlocation(t.fingerId, t.position, true));
                Touchlocation thistouch = touches.Find(x => x.touchid == t.fingerId);
                if (!Istouching)
                {
                    id = thistouch.touchid;
                }
                if (!Istouching)
                {
                    Istouching = RectTransformUtility.RectangleContainsScreenPoint(knob, thistouch.pos);
                }
            }
            else if (t.phase == TouchPhase.Ended)
            {
                Touchlocation thistouch = touches.Find(x => x.touchid == t.fingerId);

                if (Istouching)
                {
                    index = touches.FindIndex(x => x.touchid == id);
                    // Reset();
                    if (thistouch != null)
                    {
                        thistouch.istouchalive = false;
                        Istouching             = touches[index].istouchalive;
                    }
                }



                if (!Istouching)
                {
                    if (id == 0)
                    {
                        id = 0;
                    }
                    else
                    {
                        id -= 1;
                    }
                }
                if (thistouch != null)
                {
                    touches.RemoveAt(touches.IndexOf(thistouch));
                    print("Ended" + thistouch.touchid);
                }
            }
            else if (t.phase == TouchPhase.Moved)
            {
                Touchlocation thistouch = touches.Find(x => x.touchid == t.fingerId);
                if (thistouch != null)
                {
                    thistouch.pos = t.position;
                }
            }
            ++i;
        }
    }