您的位置:首页 > 移动开发 > Unity3D

unity3d 触屏拖拽物体代码

2015-11-19 10:15 337 查看
public float speed = 0.1f;
void Update() {
if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved) {
Vector2 touchDeltaPosition = Input.GetTouch(0).deltaPosition;
transform.Translate(touchDeltaPosition.x * speed, touchDeltaPosition.y * speed, 0);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: