Why is Input.GetMouseButtonUp(0) not returning true?
Why does the GetMouseButtonUp function only sometimes get called in UpdateMouseInput. Its all pretty basic and for some reason sometimes the function just isn't called. I made sure that the GetMouseButtonUp function is called in a function that is being called inside Update NOT FixedUpdate. I can see the debug logs of 'mouse updating' but 'mouse up' doesn't get logged every time the mouse button is let go.
void Update()
{
if (Input.touchSupported)
{
UpdateTouchInput();
}
else
{
UpdateMouseInput();
}
}
void UpdateMouseInput()
{
Debug.Log("Updating Mouse");
_inputPositions[0] = Input.mousePosition;
Vector3 inputDelta = _inputPositions[0] - _inputLastPositions[0];
inputDelta.x /= Screen.width;
inputDelta.y /= Screen.height;
_inputDeltas[0] = inputDelta;
if (Input.GetMouseButtonDown(0))
{
_inputLastPositions[0] = Input.mousePosition;
DispatchInputBegan(0);
}
if (Input.GetMouseButtonUp(0))
{
Debug.Log("Mouse Up");
DispatchInputEnded(0);
}
_inputLastPositions[0] = _inputPositions[0];
}
Is this an issue only when you are clicking quickly or does it also occur if you are clicking slowly? I attempted to run your code with all the excess stripped out so just the Update$$anonymous$$ouseInput and a log on the up and down detection and have no problems clicking at any speed.
If the issue is only occurring when you click fast, then perhaps whats happening is something else is causing a lag spike in which the down/up your mouse is happening faster than the input system is able to update and thus missing the message, but that would only make sense if this issue only occurs when you are clicking at a significant speed (unless you have a huge lag spike happening consistently).