Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/313.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何通过按住鼠标左键来启用bool并禁用该bool_C#_Unity3d_Boolean - Fatal编程技术网

C# 如何通过按住鼠标左键来启用bool并禁用该bool

C# 如何通过按住鼠标左键来启用bool并禁用该bool,c#,unity3d,boolean,C#,Unity3d,Boolean,我对团结很陌生 private bool scoreIncreasing; void Update() { if (Input.GetMouseButtonDown(0)) { scoreIncreasing = true; } else { scoreIncreasing = false; } } 按键或按钮有3个事件: GetMouseButtonDown在按下时仅调用一次 GetMouse

我对团结很陌生

private bool scoreIncreasing;

void Update() 
{ 
    if (Input.GetMouseButtonDown(0)) 
    { 
        scoreIncreasing = true; 
    } 
    else 
    { 
        scoreIncreasing = false; 
    }
}

按键或按钮有3个事件:

  • GetMouseButtonDown
    在按下时仅调用一次
  • GetMouseButtonUp
    在释放时仅调用一次
  • 按住按钮时的每一帧

  • 对于您的案例,请将
    GetMouseButtonDown
    更改为
    GetMouseButton

    非常感谢!祝你有美好的一天!我不明白这个问题,尤其是“如果我不在,就禁用那个bool”。。。