Canceled









How do I use Canceled
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: SwipeListenerScript.cs Copy
10  void Update () {
11   //transform.guiText.text = "my text";
12   int fingerCount = 0;
13   foreach (Touch touch in Input.touches) {
14    if (touch.phase != TouchPhase.Ended && touch.phase != TouchPhase.Canceled)
15     fingerCount++;
16
17    if (touch.phase == TouchPhase.Began)
18    {
19     startPosition = touch.position;
20     lastPosition = touch.position;
21    }
22
23    if (touch.phase == TouchPhase.Moved )
24    {
25     lastPosition = touch.position;
26    }
27    if(touch.phase == TouchPhase.Ended)
28    {
29
30     if((startPosition.x - lastPosition.x) > 80) // left swipe
31     {
32      this.Swipe ("x", -1);
33     }
34     else if((startPosition.x - lastPosition.x) < -80) // right swipe
35     {
36      this.Swipe ("x", 1);
37     }
38     else if((startPosition.y - lastPosition.y) < -80 ) // up swipe
39     {
40      this.Swipe ("y", 1);
41     }
42     else if((startPosition.y - lastPosition.y) > 80 ) // down swipe
43     {
44      this.Swipe ("y", -1);
45     }
46
47    }
48   }
49  }

Canceled 138 lượt xem

Gõ tìm kiếm nhanh...