Fast players with slow PCs

In your solution, UpdateSelectionArea() and ClearSelectionArea() only happens if the preceding conditions were not met (if-else structure). This means that if a player was really fast with their clicks and/or had a slow computer and his frame was significant amount of time long, they could press the button and release it in the same frame. Consequence would be that their selection would start but never clear, which would glitch them into constantly dragging a selection area over the screen with no mouse button pressed until he clicks again.

I think that instead all three conditions should be checked separately. (That way it is also not necessary to run UpdateSelectionArea() from StartSelectionArea().) It also looks a bit cleaner in my opinion, My Update() now looks like this:

private void Update()
{
    if (Mouse.current.leftButton.wasPressedThisFrame) StartSelectionArea();
    if (Mouse.current.leftButton.isPressed) UpdateSelectionArea();
    if (Mouse.current.leftButton.wasReleasedThisFrame) ClearSelectionArea();
}

Hi there, thanks for sharing! There are always several ways to approach one problem. Glad to see you solved this particular issue.

Privacy & Terms