Hi Unity Community! I know saving is a tough topic in the Unity3D world and yet there's a lot of resources that expounds on this topic, but I many need some ideas on how to save gameObjects and the information they carry. See, I have a custom mission editor that works with empty gameObjects and their unique scripts. Isn't there a way for me to save specific information like, saving if a gameObject's script has already executed, saving if a gameObject has been SetActive, saving lights or skyboxes, saving objects(if they are already destroyed or not). Basically, I'm trying to figure out that each time a gameObject has been SetActive or the script has already been executed, the player would be able to cut the game off and then resume right where they were with gameObjects SetActive or not, and scripts already executed or not, along with the gameObjects they may control. Which would be best for what I'm trying to do? PlayerPrefs, XML, Singleton? I'm not too familiar with the last two, so any good references would be great. Thank you!
This is what helped me. Unity live training. http://unity3d.com/learn/tutorials/...ining-archive/persistence-data-saving-loading Serializable objects that can save and load
Ok, I'm following the tutorial and I think I can make it work, it's just that I prefer Java than C#. I can translate most of the code to Java except line 5: Code (csharp): public function Load(){ if(File.Exist(Application.persistentDataPath + "/PlayerData.dat")){ var bf = new BinaryFormatter(); playerFile = File.Open(Application.persistentDataPath + "PlayerData.dat"); playerdata = (PlayerData)bf.Deserialize(playerFile); playerFile.Close(); } } Can anyone help me translate line 5 to Java Script?
I had issues converting this as well, anyway here it is: Code (JavaScript): static public function Load() { if (File.Exists (Application.persistentDataPath + "/PlayerData.dat")) { var bf: BinaryFormatter = new BinaryFormatter(); var file: FileStream = File.Open(Application.persistentDataPath + "/PlayerData.dat", FileMode.Open); var data: PlayerData = bf.Deserialize(file); file.Close(); } Hope it helps, - Lulz