手指在屏幕上的移動來旋轉物體
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class touchmove : MonoBehaviour {
float speed =0.1f;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if(Input.touchCount>0&&Input.GetTouch(0).phase==TouchPhase.Moved)
{
Vector2 touchDeltaPosition = Input.GetTouch (0).deltaPosition;
transform.Rotate (-touchDeltaPosition.y*speed,-touchDeltaPosition.x*speed,0);}
}
}
using System.Collections;
using UnityEngine.UI;
public class touchmove : MonoBehaviour {
float speed =0.1f;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if(Input.touchCount>0&&Input.GetTouch(0).phase==TouchPhase.Moved)
{
Vector2 touchDeltaPosition = Input.GetTouch (0).deltaPosition;
transform.Rotate (-touchDeltaPosition.y*speed,-touchDeltaPosition.x*speed,0);}
}
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.