C# 统一开始接触而不是检测
我想检测是否有人触摸了屏幕。为此,我在更新函数中有以下代码:C# 统一开始接触而不是检测,c#,unity3d,C#,Unity3d,我想检测是否有人触摸了屏幕。为此,我在更新函数中有以下代码: print(Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began); //Prints false if(Input.touchCount > 0) { print(Input.GetTouch(0).phase); //Prints stationary } if
print(Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began); //Prints false
if(Input.touchCount > 0)
{
print(Input.GetTouch(0).phase); //Prints stationary
}
if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began)
{
currentTrail.transform.position = cam.ScreenToWorldPoint(Input.GetTouch(0).position);
rb.position = cam.ScreenToWorldPoint(Input.GetTouch(0).position);
print("touched down"); //Doesnt get called
circleCollider.enabled = false;
currentTrail = Instantiate(trail, transform);
isCutting = true;
}
如你所见,如果statment没有接到电话,我的联系就开始了
屏幕正在检测触摸,但其相位是静止的,并且从未在开始时启动 您从哪个函数调用此代码?哪个平台?更新功能,什么意思?对不起,哪个平台?它的3d游戏是Android、iOS……或者你在电脑上运行它Editor@Programmer很明显,if语句第2行的第一行抛出了一个空错误,这就是为什么打印没有被调用,但它确实返回了我使用unity remote 5时开始的。谢谢:德古德。在构建代码并开始独立构建之前,确保代码在编辑器中工作总是很好的。这样可以节省时间。我假设您可以修复当前的空问题。如果是,那么快乐编码!