Beispiel #1
0
    public void MySave()
    {
        Inv.SaveInv(Inv.items);
        filds = new List <SaveField>();
        foreach (Transform child in GameObject.Find("Field").transform)
        {
            filds.Add(child.GetComponent <fild>().Save());
        }
        if (!Directory.Exists(Application.dataPath + "/Saves"))
        {
            Directory.CreateDirectory(Application.dataPath + "/Saves");
        }
        FileStream      fs1       = new FileStream(Application.dataPath + "/Saves/fild.sv", FileMode.Create);
        BinaryFormatter formater1 = new BinaryFormatter();

        formater1.Serialize(fs1, filds);
        fs1.Close();

        events = ListFildEvent.list;
        foreach (fildEvents ev in events)
        {
            ev.TimeLeft = new DateTime(ev.TimeEvent.Subtract(DateTime.Now).Ticks);
        }
        FileStream      fs2       = new FileStream(Application.dataPath + "/Saves/ev.sv", FileMode.Create);
        BinaryFormatter formater2 = new BinaryFormatter();

        formater2.Serialize(fs2, events);
        fs2.Close();
    }