Ejemplo n.º 1
0
    public void Save(EnemyDataCollection enemyDataCollection)
    {
        string path       = Application.dataPath + "/Resources/Data/Characters/EnemyData.xml";
        var    serializer = new XmlSerializer(typeof(EnemyDataCollection));

        using (var stream = new FileStream(path, FileMode.Create)) {
            serializer.Serialize(stream, enemyDataCollection);
            Debug.Log("Saved XML to " + path);
        }
    }
Ejemplo n.º 2
0
    public void LoadEnemyData()
    {
        listEnemyData.Clear();
        TextAsset textAsset  = Resources.Load("Data/Characters/EnemyData") as TextAsset;
        var       serializer = new System.Xml.Serialization.XmlSerializer(typeof(EnemyDataCollection));

        using (var reader = new System.IO.StringReader(textAsset.text))
        {
            this.enemyDataCollection = (EnemyDataCollection)serializer.Deserialize(reader);
        }

        listEnemyData = enemyDataCollection.ListEnemiesData;
    }