我使用这个触摸脚本来在触摸屏幕时显示一些效果:
var ParticleA : GameObject;
//var bulletHole : GameObject;
function Update () {
var hit : RaycastHit;
// Use Screen.height because many functions (like this one) start in the bottom left of the screen, while MousePosition starts in the top left
var ray : Ray = Camera.main.ScreenPointToRay (Input.mousePosition);
if (Input.GetMouseButtonDown(0))
{
if (Physics.Raycast (ray, hit, 200))
{
var newparA = Instantiate(ParticleA, hit.point, Quaternion.identity);
//var hitRotation = Quaternion.FromToRotation(Vector3.up, hit.normal);
//Instantiate(bulletHole, hit.point, hitRotation);
Destroy(newparA, 12.0);
}
}
}
它不适用于 Android。触摸时,它仅在中央屏幕上显示效果,而不是我的手指实际触摸的位置。
问题可能是什么?
最佳答案
您不想使用Input.GetMouseButtonDown(0)
(这是针对鼠标的...正如名称所示)。
使用Input.touches
:http://docs.unity3d.com/Manual/MobileInput.html
关于android - Unity Android 触摸无法按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32132354/