Unity3d实现Android滑动屏幕移动3D物体

原文链接:http://blog.csdn.net/u013108312/article/details/52575750

新建一个Cube,添加脚本:TestInput.cs

using UnityEngine;
using System.Collections;

public class TestInput : MonoBehaviour {

    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,0f, touchDeltaPosition.y * speed);
        }
    }
}

你可能感兴趣的:(Unity3d游戏功能实现汇总)