0
我有一个问题,在Unity中的GetKeyDown。即使日志似乎在每次按下按钮时都会检测到,但它并不总是执行代码。似乎在快速按下按钮时会发生更多情况。我想要的是减少“计数”直到零,然后在x秒后重新填充到其初始值。GetKeyDown行为奇怪,Unity,C#
int counting = 5;
void Update(){
if(Input.GetKeyDown(KeyCode.O) && counting > 0){
counting --;
}
else if(counting <= 0)
{
Invoke ("ResetCounting",3);
}
print (counting);
}
void ResetCounting()
{
counting = 5;
}
当然,当你说出这些话时,现在有很多意义。谢谢! – user3412636