Creating a shop on a separate scene.

I have created a relatively simple 2D game where a hot air balloon is being chased and can shoot the chasers. The player has options of multiple guns that change the damage and fire rate which are both variables in the shooting script. I have then created a shop scene which changes the variables in the shooting script. The gunManager script (which changes the variables in the shooting script) has a DontDestroyOnLoad on it… The shop works if I open it first and then open the game scene (the variables are changed and the damage and wait time of the gun is correct). However when I close the game, reopen the shop and pick a different gun, it has no impact in the game scene I tried
GameObject objs = GameObject.FindGameObjectsWithTag(“GunManager”);
if (objs.Length > 1)
as I thought the problem was multiple gunManager scenes were open. This completely broke the whole mechanic.

Is there any way I can fix this or is there a simpler way to make my shop?


hey ;
first of all u should not use DontDestroy for some thing like this ;
it is for Instancing and other stuff;
for shoping and upgrading you should save data in the shop scene and then load the saved data in the game scene;
for example for your gun you can save a damage value like this :

    PlayerPrefs.SetInt("Gun1Damage " , 10 );
    PlayerPrefs.SetInt("Gun2Damage " , 20 );
    PlayerPrefs.SetInt("Gun3Damage " , 60 );

then in the game scene u can load it like this :

    myGun1.Damage = PlayerPrefs.GetInt("Gun1Damage");
   myGun2.Damage = PlayerPrefs.GetInt("Gun2Damage");
   myGun3.Damage = PlayerPrefs.GetInt("Gun3Damage");