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);
}
}
unity3d 触屏拖拽物体代码
最新推荐文章于 2024-06-24 16:47:20 发布