Hi,
I’ve got a standalone Unity application using the ‘DragRigidBodies’ script provided within the Standard Assets Package.
This application is accessed by a touchscreen (single touch only).
After a ~24 hours I find the application has it’s input stuck down (as though someone is holding their finger down on the screen constantly). The application hasn’t frozen however, the touch input just seems to have gotten stuck down.
Deployed as standalone x64 on Windows 8.1 desktop.
Anyone else run into this issue before?
TLDR; Running unity over extended periods of time causing input to get stuck.
It’s difficult to know what’s happening without a little more context. However, if you have something similar to:
void Update () {
while (Input.GetMouseButton(0)) {
Debug.Log ("Left mouse button is down");
}
}
as your subject line suggests, then I wouldn’t expect it to ever exit once the left mouse button is pressed as the results of Input.GetMouseButton are only updated per frame (and you must exit the while loop to continue onto the next frame) so the above code will enter a never ending loop.
Perhaps the code should use an ‘if’ instead of ‘while’?
void Update () {
if (Input.GetMouseButton(0)) {
Debug.Log ("Left mouse button is down");
}
}
Sorry, let me provide more context for you.
This is taken from the DragRigidbody script in the Standard Unity Assets, for which I’ve modeled my own script after. In it’s bare elements it looks like this:
void Update(){
if (!Input.GetMouseButtonDown(0)){
return;
}
StartCoroutine("DragRigidbody", hit.distance);
}
IEnumerator DragObject(float distance){
while (Input.GetMouseButton(0)){
Debug.Log("Left mouse button is down");
yield return null;
}
}
As I was saying, It works for roughly ~24 hours before an issue occurs, and after further testing, I believe it may not occur on the Windows 7 OS, but it definitely does on Windows 8.1.
Cheers,