public IEnumerator LoadTowersWeb() { WWW www = null; #if !UNITY_EDITOR int indexPageIndex = Application.absoluteURL.IndexOf("index.html"); if (indexPageIndex < 0) { indexPageIndex = Application.absoluteURL.Length; } baseUrl = Application.absoluteURL.Substring(0, indexPageIndex - 1); #endif www = new WWW(string.Format("{0}/Data/Towers.xml", this.baseUrl)); yield return(www); if (string.IsNullOrEmpty(www.error)) { var serializer = new XmlSerializer(typeof(TowersArray)); TextReader textReader = new StringReader(www.text); towers = serializer.Deserialize(textReader) as TowersArray; textReader.Close(); } loadedTowers = true; }
public void LoadTowers() { string towersPath = GetPath("Towers.xml"); if (File.Exists(towersPath)) { var serializer = new XmlSerializer(typeof(TowersArray)); var stream = new FileStream(towersPath, FileMode.Open); towers = serializer.Deserialize(stream) as TowersArray; stream.Close(); } }