【发布时间】:2014-07-10 17:17:59
【问题描述】:
尝试在 x 和 y 轴上拖放游戏对象。由于某种原因,即使鼠标没有移动,x、y 和 z 的值也会随着时间的推移而变小。谁能解释为什么会这样?
using UnityEngine;
using System.Collections;
public class Drag : MonoBehaviour {
Vector3 point;
float x;
float y;
float z;
void Update () {
}
void OnMouseDrag()
{
x = Input.mousePosition.x;
y = Input.mousePosition.y;
z = gameObject.transform.position.z;
point = Camera.main.ScreenToWorldPoint (new Vector3 (x, y, z));
gameObject.transform.position = point;
Debug.Log ("x: " + point.x + " y: " + point.y + " z: " + point.z);
}
}
【问题讨论】:
标签: c# user-interface unity3d