Is it possible to load a scene with playerprefs with a save and load button? I just need it to load in the scene that the player was last in once they press the save button and load the scene with the load button. Is that possible or would I have to use something else?
I don’t think thats it, what I’m trying to say is when I click the save button it saves just the scene I am in and when I click the load button it loads that scene.
Like, saves the current state of the scene and the state of all the objects inside it? There’s nothing that will do that automatically for you. You need to build your own save/load system.
If you’re just trying to save which scene the player is in, and not the entire state of the world, then you can save the scene name or number and use that.
Yeah, like Praetor said above, that’s a thing you make, but luckily there’s like fifty billion (at least) Youtube tutorials on doing it. Work through one or two and get a feel for what’s involved.
I was looking for what antistone is talking about not what you guys but I think I found a way to do it so thanks for the help.
I found out how to do it this code did the trick thanks to Antistone thx bro!!!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class save : MonoBehaviour
{
public void SaveGame()
{
PlayerPrefs.SetInt("Level", SceneManager.GetActiveScene().buildIndex);
PlayerPrefs.Save();
print("Game saved!");
}
public void LoadGame()
{
SceneManager.LoadScene(PlayerPrefs.GetInt("Level"));
print("Game loaded!");
}
}
This is awesome. Thank you @nckazzi