- Home /
How to change save from button to automatic
How to make the selected scene automatically saved in Unity? E.g. I would like the 3rd, 6th and 9th scene to be saved automatically. How do I do this? This is my code which works only on the button unfortunately:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class Scene_Manager : MonoBehaviour
{
int Saved_scene;
int Scene_index;
public void new_game()
{
SceneManager.LoadSceneAsync(1);
}
public void Load_Saved_Scene()
{
Saved_scene = PlayerPrefs.GetInt("Saved");
if(Saved_scene != 0)
SceneManager.LoadSceneAsync(Saved_scene);
else
return;
}
public void Save_and_Exit()
{
Scene_index = SceneManager.GetActiveScene().buildIndex;
PlayerPrefs.SetInt("Saved", Scene_index);
PlayerPrefs.Save();
SceneManager.LoadSceneAsync(0);
}
public void Next_Scene()
{
Scene_index = SceneManager.GetActiveScene().buildIndex + 1;
SceneManager.LoadSceneAsync(Scene_index);
}
}
Comment
Your answer
