Unity的安卓上的移动C#脚本

来源:互联网 发布:nginx伪静态规则写法 编辑:程序博客网 时间:2024/06/03 07:57

using UnityEngine;
using System.Collections;

public class MobileMove : MonoBehaviour {
 public float speed = 0.3F;
 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);
  }
 }
}

0 0
原创粉丝点击