// Use this for initialization void Start() { data = GetComponent <DataManager>(); //persistentData = new AppData(); bgaData = new JSONObject(bgaTableData.text); gameToLaunch = new GameSpecs(); onlineGameInterface = new Multi.Interface(); gameSaved = new GameState(); #if !UNITY_EDITOR || PERSISTENT_DATA loadAppData(); #endif if (musicOn) { GameObject.FindGameObjectWithTag("BGM").GetComponent <AudioSource>().Play(); } else { Transform musicButtons = GameObject.Find("MenuUI").transform.Find("Options menu/Music slider"); musicButtons.Find("On").gameObject.SetActive(false); musicButtons.Find("Off").gameObject.SetActive(true); } initializationDone = true; }
private void Initialise() { blinds = FindObjectOfType <GameUI.BlindController>(); hud = FindObjectOfType <GameUI.MainHUD>(); menu = FindObjectOfType <GameUI.MainMenu>(); emmiter = FindObjectOfType <BubbleEmmiter>(); sound = FindObjectOfType <SoundStorage>(); musicPlayer = FindObjectOfType <MusicManager>(); spec = LoadSpec(); }
public static bool Save(GameSpecs specs) { switch (Application.platform) { case RuntimePlatform.Android: { return(SaveSpecsAndroid(specs)); } default: { return(SaveSpecsDefault(specs)); } } }
public static bool Load(out GameSpecs specs) { Debug.Log("Try to load settings."); switch (Application.platform) { case RuntimePlatform.Android: { return(LoadSpecsAndroid(out specs)); } default: { return(LoadSettingsDefault(out specs)); } } }
private static bool SaveSpecsDefault(GameSpecs specs) { string path = Application.streamingAssetsPath + "/specs.dat"; try { XmlSerializer formatter = new XmlSerializer(typeof(GameSpecs)); // получаем поток, куда будем записывать сериализованный объект using (FileStream fs = new FileStream(path, FileMode.Create)) { formatter.Serialize(fs, specs); } Debug.Log(path + " - saved(default)"); return(true); } catch (Exception e) { Debug.Log(e.Message); return(false); } }
private static bool LoadSettingsDefault(out GameSpecs specs) { string path = Application.streamingAssetsPath + "/specs.dat"; // передаем в конструктор тип класса XmlSerializer formatter = new XmlSerializer(typeof(GameSpecs)); specs = new GameSpecs(); // десериализация try { FileStream fs = new FileStream(path, FileMode.Open); specs = (GameSpecs)formatter.Deserialize(fs); Debug.Log(path + " - ok"); fs.Close(); Debug.Log("Settings loaded."); return(true); } catch (Exception) { Debug.Log("Set default"); return(false); } }