Save a Image's state

I have a script that saves how many points a player has between scenes, but i wonder if it’s possible to make it so it saves the state of a image. The image is gone be “SetActive” from another scene, and then i need a script that remember which state the image is in. Thanks in advance :slight_smile:75633-image.pngThe two states is when this button is pressed and when it’s not.

And this is the script that saves between scenes:

using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;

public class GameStatus : MonoBehaviour {

public int score = 0;

void Start () {
	score = PlayerPrefs.GetInt ("score", 0);

}

void Update () {

}
void OnDestroy(){
	Debug.Log ("Fail");
	PlayerPrefs.SetInt ("score", score);
	
}
public void AddScore(int s){
	score += s;
}
public int GetScore(){
	return score;
}
public void LoadScene(string sceneName){
	SceneManager.LoadScene (sceneName);
}

}

Hello and god day, so, what you are trying to do is set some state on a particular button and keep it until the next or previous scene, right?.

I remember done something like this some time a go, that was enable/disable the music/sounds, showing the button state on the main menu and in a second menu, I found that the best way to do this is using an “inmortal” game object, this means that the object who is holding the main data from the game/app keeps in all the scenes and when it is necesary saves this data in the prefs.

To achieve this just use the DontDestroyOnLoad(object), this allows you to keep alive the desired object through all you scenes, check the documentation abouthis, cheers.