I've been watching these xml-saving tutorials for a while and I must say this is the best one of them.
@beaverjoe91714 жыл бұрын
VBFilms thx for your high likes!!!!
@rulyhyperion82773 жыл бұрын
This is the first save/load thing that worked for me, and it's quick and easy to use. Thank you very much
@gregspot95384 жыл бұрын
Muchas gracias amigo, sinceramente el mejor video para guardar y leer archivo XML. THXXX SO MUCH!!!!
@PhazonBlaxor2 жыл бұрын
There is no need to use tags and to write every single variable individually (that's really confusing and waste of time), just make the data class you want to save serializable, then use XmlSerializer to write the whole class in one go to a XML-file. To load, you simply reverse the process. Like so: public void Save() { if (!Directory.Exists(Application.persistentDataPath + folderName)) //If folder does not exist, create it { Directory.CreateDirectory(Application.persistentDataPath + folderName); Debug.Log("Created data path"); } XmlSerializer serializer = new XmlSerializer(typeof(Save)); //Set the Save class to be serialized FileStream stream = new FileStream(Application.persistentDataPath + folderName + fileName + fileExtension, FileMode.Create); //Setting FileMode to Create to write the file serializer.Serialize(stream, _save); //_save is a reference to the serializable Save class, just make the reference however you wish to do it. stream.Close(); //Always remember to close the stream! } public void Load() { if(File.Exists(Application.persistentDataPath + folderName + fileName + fileExtension)) //We only load if the save file actually exists { XmlSerializer serializer = new XmlSerializer(typeof(Save)); //We do the same process as with saving FileStream stream = new FileStream(Application.persistentDataPath + folderName + fileName + fileExtension, FileMode.Open); //Set FileMode to Open to access the data file _save = (Save)serializer.Deserialize(stream); //Deserialize the file and cast it as Save data (or whatever your data class is called) stream.Close(); //Once again, you must close the stream or you lock the access. } else { Debug.LogWarning("Save File Not Found!"); } } That's all you need to do! Just modify the variables in the Save class directly in-game, so you don't need duplicates and to remember tens of tags. Simple, eh? Note: You need to be using System.Xml.Serialization to access the serialization classes.
@PassiveSnack4 жыл бұрын
Great video, just what I needed! My appreciation is immeasurable! Subscribed.
@beaverjoe91714 жыл бұрын
PassiveSnack thx so much. If u try to use methods save and load data on webGL, only one method can work. I remember is xml. But I am stilling finding any solutions on unity forum. There are the same issues someone faced on forum. Btw. Happy New Year!!🎈🎊
@elladitch96985 жыл бұрын
OMG this is just what I want. Thx man, u really help a lot!
@beaverjoe91715 жыл бұрын
Thanks! 😁
@nikitazuev33315 жыл бұрын
You are the best. Thanks for tutorial. But one question, how to add at the TOP?
@beaverjoe91715 жыл бұрын
Thanks for your likes and comments. Happy ThanksGiving! 🎈 💫The XML declaration typically appears as the first line in an XML document. The XML declaration is not required. 🥬 If you want to add, You can open your XML file and add it to the top I think. (You can try it but I do not promise. I remember when I learned HTML, I did not use this line but all works 🍄)
@nikitazuev33315 жыл бұрын
@@beaverjoe9171 Unfortunately without this line my native language (cyrillic) dont reading. Ok. One more question, how to assign an attributes? XmlNodeList LoadedEnemys = XmlDoc.GetElementsByTagName("Enemys"); No problem, but how to use: XmlDoc.Attributes["Value1"].Value; ???? Thanks.
@VBFilms4 жыл бұрын
I just moved my unity project to another computer and now I'm getting an error "Input string was not in correct format". Even though it is. It seems Unity can't parse my float numbers. If I make the values whole numbers it works, but the problem comes from the floats. This worked on my other computer.
@yvesevrard24214 жыл бұрын
Thanks man, good videos
@beaverjoe91714 жыл бұрын
Thx for your likes. There is much more to come in the next year!