【发布时间】:2015-02-06 20:08:52
【问题描述】:
我正在 Unity3D 中为触摸屏设备制作 2D 游戏,并且我正在尝试制作类似“GetMouseButtonDown”的东西。这是我的代码:
if (Input.touchCount > 0) {
foreach (Touch touch in Input.touches) {
Vector3 i = Camera.main.ScreenToWorldPoint (touch.position);
RaycastHit2D hit = Physics2D.Raycast (i, i);
if (hit.transform != null) {
string tag = hit.transform.gameObject.tag;
if (touch.phase == TouchPhase.Began) {
hit.transform.localScale = new Vector2(-transform.localScale.x, -transform.localScale.y);
}
}
}
}
我希望被击中的对象改变比例。如果我使用“GetMouseButtonDown”,我希望它会是这样。然而,结果,我按下它,它的比例改变了,但只有一次。我再次按下,没有任何反应。我该怎么办?
【问题讨论】:
标签: android input unity3d touch