在帧/循环的剩余时间忽略鼠标输入事件
本文关键字:鼠标 入事件 输入 时间 循环 余时间 在帧 | 更新日期: 2023-09-27 18:29:58
在我处理MouseUp事件后,我想为这个周期禁用if。有没有一种方法可以编辑这个只读变量,或者在触发后禁用它?
if (Input.GetMouseButtonUp(0)){
Debug.Log("a");
// What I am looking for
Input.MouseButtonUp = false;
}
if (Input.GetMouseButtonUp(0)){
// This should then no longer trace
Debug.Log("b");
}
我知道在这种情况下,我可以使用if/else开关。我的问题是函数在不同的类中。
您可以尝试使用协同程序。
bool canPress = true;
IENumerator DisableInput()
{
canPress = false;
yield return new WaitForEndOfFrame();
canPress = true;
}
if (Input.GetMouseButtonUp(0) && canPress){
Debug.Log("a");
Input.MouseButtonUp = false;
}
if (Input.GetMouseButtonUp(0) && canPress){
// This should then no longer trace
Debug.Log("b");
}