incrementing by 1

In the update function how to increment a vlaue only by one. If i do count++ it will keep on increasing but every time the event ends i want it to increase only by one.

Here is the script

void Test()
{
        if(win > 0)
		{
			count++;
		}
		else
		{
			count = 0;
		}

		Debug.Log("count = "+count);

		if(PlayerPrefs.GetInt("first") == 0)
		{
			if(count == 1)
			{
				Debug.Log("First point");
				PlayerPrefs.SetInt("first", 1);
			}
		}
		else
		{
			if(count == 2)
			{
				Debug.Log("Second point");
			}
			else if(count == 3)
			{
				Debug.Log("Third point");
				count = 0;
			}
		}	
}

I am calling this Test() in Update().

Since it is still unclear under which conditions exactly you want count to increase (or who sets win, or for how long it stays >0, or for how long you want it to stay >0), we are forced to guess what you want.

I am now guessing that “win” becomes >0 at some point, and if it does, “count” should increase by exactly one, as long as win>0. Then at some point win becomes 0. Nothing happens. Then at some point win becomes >0 again, and only then do you want count to increase.

If that is the case, this will help:

int oldWin=0;
void Test(){
    if(win>0 && oldWin==0){ // win just became >0
        count++;

        // move all your stuff that does something on a count change here
    }
    oldWin=win; // update state to prevent the code above from being executed again
}

If not, explain some more.