A problem with making an object appear after changing a PlayerPref value.

Hello! I’ve been working on a game recently and wanted to add a function that would make an object active after a specific upgrade is purchased and make it stay active forever after the upgrade is obtained (unless the player resets his/her progress).

I tried approaching it like this:

The script on the upgrade button gets the amount of times it has been bought and stores it in a PlayerPref Int.

   void Update () {
    		PlayerPrefs.SetInt ("itemcount",item.count);
    	}

The code on the object that becomes active checks if the item count is equal or above 1 ( so the upgrade was purchased) and makes the gameObject active if it’s true.

void Update () {
	
	if (PlayerPrefs.GetInt("itemcount") >= 1)
	{
		gameObject.SetActive(true);
	}
	else
	{
		gameObject.SetActive(false);
	}
 }
}

The problem here is that the code works, but the game object will appear only after you restart the scene/game. I want it to appear right after you purchase the upgrade, how do I fix my code? Thanks it advance!

PlayerPrefs.Save

By default Unity writes preferences to disk during OnApplicationQuit(). In cases when the game crashes or otherwise prematuraly exits, you might want to write the PlayerPrefs at sensible ‘checkpoints’ in your game. This function will write to disk potentially causing a small hiccup, therefore it is not recommended to call during actual gameplay.