[英]Unity2d (C#) how to detect when a player clicks anywhere on the screen?
I'm trying to detect if a player clicks anywhere on the screen, then do some code but I can't get it to work.我试图检测玩家是否点击了屏幕上的任何位置,然后执行一些代码,但我无法让它工作。 I've tried several different snippets of code I found online, but none of them worked.我尝试了几个在网上找到的不同代码片段,但都没有奏效。
if (Input.GetMouseButtonDown(1) && Note1.activeInHierarchy == true)
{
PaperClose.Play();
Note1.SetActive(false);
}
我发现了问题,我只需要将鼠标按钮的检测放在“void Update()”函数中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.