首先,input.touchcount不能在mac上运行时使用,在android上可以,mac 上可以用GetMouseButton(0),
在发布android的时候需要修改bundle identifier的公司名,否则不能发布,
然后,下面是绑定在主摄像机上的脚本,暂时实现放大缩小,拖动等效果
using UnityEngine;
using System.Collections;
public class camera : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
float speed = 1f;
Vector2 beginPosition0 ;
Vector2 beginPosition1 ;
Vector2 endPosition0 ;
Vector2 endPosition1 ;
void Update () {
if (Input.touchCount == 1 ) {
Debug.Log ("move1");
if (Input.GetTouch (0).phase == TouchPhase.Moved) {
Debug.Log ("move");
Vector2 touchDeltaPosition = Input.GetTouch (0).deltaPosition;
transform.Translate (-touchDeltaPosition.x * speed,
-touchDeltaPo