Example #1
0
    void Start()
    {
        ic = IncidentContainer.Load(path);

        icNames = new string[ic.incidents.Count];

        int index = 0;

        foreach (Incident i  in ic.incidents)
        {
            icNames [index] = i.name;
            index++;
        }

        // DEBUG

        /*
         * for (int i = 0; i < icNames.Length; i++) {
         *      Debug.Log (icNames [i]);
         * }
         */

        // DEBUG

        /*
         * foreach(Incident i in ic.incidents){
         *      Debug.Log(i.name);
         *      Debug.Log(i.effect);
         *      Debug.Log(i.duration);
         *      Debug.Log(i.description);
         * }
         */
    }
    public static IncidentContainer Load(string path)
    {
        TextAsset _xml = Resources.Load <TextAsset> (path);

        XmlSerializer serializer = new XmlSerializer(typeof(IncidentContainer));

        StringReader reader = new StringReader(_xml.text);

        IncidentContainer incidents = serializer.Deserialize(reader) as IncidentContainer;

        reader.Close();

        return(incidents);
    }