Im new to unity and im trying to do the tanks tutorial, to progress further i need to save the scene, but unity won’t let me save in the assets folder, because i “need to save in the assets folder”. im stuck in a loop, pls help in anyway possible
This function should do it:
void SaveWorld() {
//Save a scene to HDD/SSD
Game saveGame = new Game(); //Replace "Game" with the file name that you are trying to serialize
saveGame.name = SceneManager.GetActiveScene().name; //This is an example of how you can save
//stuff like the name of the game
//Save any other information here
BinaryFormatter bf = new BinaryFormatter();
FileStream file = File.Create(Application.dataPath + "/Saves/" + saveGame.name + ".prefix");
//Application.dataPath refers to the assets folder when you are playing from editor.
//Note that this example requires you to have a
//subfolder of the assets folder called "Saves".
//You can make the path whatever you want. If you
//don't want to save it in a subfolder just
//delete " + "/Saves/". The prefix can also be whatever you want.
bf.Serialize(file, saveGame);
file.Close();
Debug.Log("Saved Game: " + saveGame.name + "
Path: " + Application.dataPath + “/Saves/” + saveGame.name + “.prefix”);
}
You say that you are new to Unity so you probably want to read or watch some tutorials on how to properly save and load data from a hard drive. It’s not hard but this function is only the bare necessities. Here’s a tutorial provided by Unity: https://unity3d.com/learn/tutorials/topics/scripting/serialization-and-game-data
this is a very big bug that frustrates beginners developers should not answer the questions in this forum