Quantcast
Channel: Latest Questions by TheShadyColombian
Viewing all articles
Browse latest Browse all 145

Read AND Write to XML at runtime

$
0
0
I want to create a custom file save with XML (I don't like the way PlayerPrefs does it) but from what I've read, the way I'm doing it right now won't allow me to write/modify the file at runtime, which defeats the whole purpose of it. I don't really care if the file is human-readable like the PlayerPrefs xml file is, as long as it's read and write. Here's the script I'm using for accessing the file and whatnot, but there's no write-to method yet (as that's when I hit a hitch on the road): using System.Collections; using System.Collections.Generic; using UnityEngine; using System.Xml.Serialization; using System.IO; [XmlRoot("LevelCollection")] public class XML_LevelCollection { [XmlArray("Levels")] [XmlArrayItem ("Level")] public List Levels = new List (); public static XML_LevelCollection Load (string path) { TextAsset LevelContainerXML = Resources.Load (path); XmlSerializer Serializer = new XmlSerializer (typeof (XML_LevelCollection)); StringReader Reader = new StringReader (LevelContainerXML.text); XML_LevelCollection levels = Serializer.Deserialize (Reader) as XML_LevelCollection; Reader.Close (); return levels; } }

Viewing all articles
Browse latest Browse all 145

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>