标签:android blog class code c tar
Unity中获取到的坐标是左下角为(0,0)
但是绘画的时候是以左上角为(0,0)
所以直接在获取到的坐标上画图是不行的……
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37 |
using
UnityEngine; using
System.Collections; public
class MultiTouch : MonoBehaviour { public
Texture2D imageBG; public
Texture2D imageItem; void
OnGUI() { GUI.DrawTexture( new
Rect(0,0,640,960),imageBG); int
touchCount=Input.touchCount; for ( int
i=0;i<touchCount;i++) { Vector2 touchposition= Input.GetTouch(i).position; int
x=( int )touchposition.x; int
y=( int )touchposition.y; GUI.DrawTexture( new
Rect(x,960-y,120,120),imageItem); GUI.Label( new
Rect(x,960-y,120,120), "Touch position is " +touchposition); } } // Use this for initialization void
Start () { } // Update is called once per frame void
Update () { } } |
把代码拖到MainCamera上,然后把两张图片拖到imageBG、imageItem赋值。编译成APK。放到手机上就看到效果啦。这个是一个手五点触控的图片。
《转》Unity Android/IOS 多点触摸实例,布布扣,bubuko.com
标签:android blog class code c tar
原文地址:http://www.cnblogs.com/dawn-cn/p/3734031.html