iOSでタッチパネルからどのような情報が取得できるかを表示するアプリを作成しました。

上の画像のように、タッチしたところに渦マークを表示し、その右側にタッチの詳細情報を表示する、というアプリです。
- http://docs.unity3d.com/Documentation/ScriptReference/Input-touches.html
- http://docs.unity3d.com/Documentation/ScriptReference/Touch.html
Touch
fingerId
- The unique index for touch.
position
- The position of the touch.
deltaPosition
- The position delta since last change.
deltaTime
- Amount of time passed since last change.
tapCount
- Number of taps.
phase
- Describes the phase of the touch.
iOS-Touch3
こうやって遊んでみると結構楽しいです。5本の指のタッチもきちんと認識するのには驚きました。上の動画は時計回りに90度回転させるイメージで見てください。
ソースコード
import UnityEngine #Boo
class touch (MonoBehaviour):
public tex as Texture
texsize as Vector2
def Start ():
texsize= Vector2(tex.width/2, tex.height/2)
def Update ():
pass
def OnGUI():
for touch as Touch in Input.touches:
rect as Rect = Rect(touch.position.x-texsize.x/2, Screen.height-touch.position.y-texsize.y/2, texsize.x, texsize.y)
GUI.DrawTexture(rect, tex)
rectl as Rect = Rect(touch.position.x+texsize.x/2, Screen.height-touch.position.y-texsize.y/2, 200,400)
GUI.Label(rectl,
"fingerId="+touch.fingerId+"\nposition="+touch.position.ToString ()+"\ndeltaPosition="+touch.deltaPosition
+"\ndeltaTime="+touch.deltaTime+"\ntapCount="+touch.tapCount+"\nphase="+touch.phase
);
ダウンロード
unityのプロジェクトはこちら。