public void Inc() { if (x < 5) { x++; Debug.Log(x); } else Debug.Log("Done"); }
The Inc () method of your code always displays the message "Done" in the log, because if the condition (x <5) is true, then there is no way out. Therefore, it is necessary either after if to use else, or after Debug.Log (x) to use return.
Only now drew attention to the "five clicks." In this case, after checking x <5, one should also check for equality 5. Then, in one execution of Inc (), the increment and output of the message that the task is completed will be possible.
if (x < 5) { x++; Debug.Log(x); } if (x == 5) Debug.Log("Done");