Beginner - help with Buttons keeping their state between scenes

There is a couple of confusing posts that are near what I need to understand. But they just confuse me.

I guess the question is how do we store data from one screen to another. Dose the data get actually passed to the next screen or do we just recreate it? Can I make a persistent space to store settings of a toggles for example? So then no data is exchanged through the scene but the scene would reference the persistent space to get those details. These are all assumptions from a fledgling beginner.

  • I have three scenes and I have menu in scene 1 and buttons in scene 2 and 3. Those are all working fine. I can navigate between the scenes.

-I have a " toggle" (On/Off)(check mark) in scene 2 and I have a duplicate of the toggle on the menu page ( scene 1 ).

  • when I enable the toggle in scene 2, then change to the menu. Once i return to original scene. The toggle is back to its original state.

I want to keep the “state” of the toggle between scenes. Furthermore, I want to duplicate the state of the toggle in scene 1, with the state of the toggle in scene 2 ( menu).

I think this could be written in some master script. But seeing that it would be more efficient to attach states to a GameObject and then only need to write the kind of mechanic script that could be attached to the Game Object and be reused in similar situations. But how do you get a Gameobject higher in the hierarchy so its a controller for all of these type of stored states?

The ask:
Anyway, I do have a little experience writing scripts like powershell, c++. But very junor. If anyone can get me going in the right direction without too much pain that would be greatly appreciated. I can provide further details if need, again thanks!

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class rememberstate : MonoBehaviour
    //Toggle game Object
    public Toggle istoggle;

    //Check active toggle
    public void ActiveToggle()


        if (istoggle.isOn)
            UnityEngine.Debug.Log("Toggle is Active");
            PlayerPrefs.SetInt("Firstkey", 1);
        else //if (istoggle == false)
            UnityEngine.Debug.Log("Toggle is off");
            PlayerPrefs.SetInt("Firstkey", 2);
       // {
          //  UnityEngine.Debug.Log("Toggle");
      //  }

    public void Onclick()

        //check active toggle through function

this script works the first time but when I try again it stays at the last debug msg even if the toggle is off…