Esempio n. 1
0
    public static void Load()
    {
        string path = Application.persistentDataPath + "/config.pushcube";
        ConfigurationDataFormat data = null;

        if (File.Exists(path))
        {
            BinaryFormatter formatter = new BinaryFormatter();
            FileStream      stream    = new FileStream(path, FileMode.Open);
            data = formatter.Deserialize(stream) as ConfigurationDataFormat;
            stream.Close();
        }
        if (data != null)
        {
            ConfigurationData.bgmSound = data.bgmSound;
            ConfigurationData.efxSound = data.efxSound;
            ConfigurationData.vibrate  = data.vibrate;
            ConfigurationData.language = data.language;
            ConfigurationData.theme    = data.theme;
        }
        else
        {
            Debug.LogWarning("설정 데이터를 찾을 수 없습니다. " + path);
            Init();
        }
    }
Esempio n. 2
0
    public static void Save()
    {
        BinaryFormatter formatter = new BinaryFormatter();
        string          path      = Application.persistentDataPath + "/config.pushcube";
        FileStream      stream    = new FileStream(path, FileMode.Create);

        ConfigurationDataFormat data = new ConfigurationDataFormat();

        try
        {
            formatter.Serialize(stream, data);
        }
        catch (SerializationException e)
        {
            Debug.LogError("설정 데이터 저장 실패 > " + e.Message);
            throw;
        }
        finally
        {
            stream.Close();
        }
        Debug.Log("설정 데이터 로컬 저장완료.");
    }