Exemple #1
0
 public bool LoadData()
 {
     Debug.Log(Application.persistentDataPath);
     if (File.Exists(Application.persistentDataPath + "/patterns.dat"))
     {
         FileStream      file;
         BinaryFormatter bf = new BinaryFormatter();
         file   = File.Open(Application.persistentDataPath + "/patterns.dat", FileMode.Open);
         patstr = (PatternsStruct)bf.Deserialize(file);
         Debug.Log("Number of types (" + Types.Count + "), groups(" + LowGroups.Count + "), patterns: " + Patterns.Count);
     }
     else
     {
         return(false);
     }
     return(true);
 }
Exemple #2
0
    // Explicit static constructor to tell C# compiler
    // not to mark type as beforefieldinit
    void Awake()
    {
        if (manager == null)
        {
            if (!LoadData())
            {
                patstr = new PatternsStruct();
                initTypes();
            }

            DontDestroyOnLoad(gameObject);
            manager = this;
        }
        else if (manager != this)
        {
            Destroy(gameObject);
        }
    }