コード例 #1
0
    void Awake()
    {
        if (!s_instance)
        {
            s_instance = this;
        }
        else
        {
            Destroy(gameObject);
        }

        savePath               = Application.persistentDataPath + "/saveNeeds.dat";
        needs                  = new NeedsObject();
        needs.eatDateAndTime   = new int[5];
        needs.drinkDateAndTime = new int[5];
        LoadNeeds();
    }
コード例 #2
0
 void LoadNeeds()
 {
     if (File.Exists(savePath))
     {
         BinaryFormatter bf   = new BinaryFormatter();
         FileStream      file = File.Open(savePath, FileMode.Open);
         needs = (NeedsObject)bf.Deserialize(file);
         file.Close();
     }
     else
     {
         Debug.LogWarning("Did not find the file Application.persistentDataPath + \" / saveNeeds.dat\"\n Created one");
         UpdateDateAndTime(true);
         UpdateDateAndTime(false);
         SaveNeeds();
     }
 }