首先,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,
-touchDeltaPosition.y * speed, 0);
}
}
if (Input.touchCount == 2 ) {
if (Input.GetTouch (0).phase == TouchPhase.Moved &a

这篇博客介绍了在Unity3D中如何处理多点触摸事件。内容提及input.touchcount在Mac上不可用,但在Android上可以,并推荐使用GetMouseButton(0)作为替代。在发布Android应用时,需要注意修改bundle identifier的公司名以避免发布问题。博主分享了一段用于实现缩放和拖动效果的主摄像机脚本。

992

被折叠的 条评论
为什么被折叠?



