Hi everyone, I am creating a visual novel, and I created a playerprefs to save the dialogue, the position and pose of the character so when you load the game appears the exact dialogue where the player was last time, but when loading only appears the scene where the player was the last time and no dialogue or character pose
public void OnGUI()
{
if (SceneManager.GetActiveScene().name == "Scene1")
{
PlayerPrefs.SetString("dialogo", dialogue);
PlayerPrefs.SetString("name", characterName);
PlayerPrefs.SetString("position", position);
PlayerPrefs.SetInt("pose", pose);
PlayerPrefs.SetInt("line", lineNum);
PlayerPrefs.Save();
Debug.Log("save");
level = 1;
PlayerPrefs.SetInt("level", level);
PlayerPrefs.Save();
Debug.Log("guardado" + level);
}
if (SceneManager.GetActiveScene().name == "Scene3")
{
level = 3;
PlayerPrefs.SetInt("level", level);
PlayerPrefs.Save();
Debug.Log("guardado" + level);
}
if (SceneManager.GetActiveScene().name == "Scene2")
{
bool botton = GUI.Button(new Rect(200, 80, 80, 50), "load");
if (botton)
{
level = PlayerPrefs.GetInt("level");
if (level == 1)
{
SceneManager.LoadScene("Scene1");
lineNum = PlayerPrefs.GetInt("line");
transform.position = new Vector3(PlayerPrefs.GetFloat("x"), PlayerPrefs.GetFloat("y"), PlayerPrefs.GetFloat("z"));
transform.position = new Vector3(transform.position.x + 1, transform.position.y, transform.position.z);
dialogue = PlayerPrefs.GetString("dialogo");
characterName = PlayerPrefs.GetString("name");
position = PlayerPrefs.GetString("position");
pose = PlayerPrefs.GetInt("pose");
lineNum++;
}
}
}
}