예제 #1
0
    private void Awake()
    {
        DataBaseMusic data = DataWork.LoadMusic();

        musicSlider.value   = data.musicVolume;
        effectsSlider.value = data.effectsVolume;
    }
예제 #2
0
    void Awake()
    {
        _source = GetComponent <AudioSource>();
        DataBaseMusic data = DataWork.LoadMusic();

        _source.volume = data.musicVolume;
        if (main)
        {
            DontDestroyOnLoad(this.gameObject);
        }
    }
예제 #3
0
    private void Start()
    {
        source = GetComponent <AudioSource>();
        DataBaseMusic data = DataWork.LoadMusic();

        source.volume = data.musicVolume;
        GameEngine.Engine.soundEffectVolume = data.effectsVolume;

        if (GameObject.Find("MusicBox") != null)
        {
            Destroy(GameObject.Find("MusicBox"));
        }
    }
예제 #4
0
    public static void SaveMusic(float musicV, float effectsV)
    {
        //DataBase data = Load();
        //data.musicVolume = musicV;
        //data.effectsVolume = effectsV;

        BinaryFormatter formatter = new BinaryFormatter();
        string          path      = Application.persistentDataPath + "/Sound.vol";
        FileStream      stream    = new FileStream(path, FileMode.Create);

        DataBaseMusic data = new DataBaseMusic(musicV, effectsV);

        formatter.Serialize(stream, data);
        stream.Close();
    }
예제 #5
0
    public static DataBaseMusic LoadMusic()
    {
        string path = Application.persistentDataPath + "/Sound.vol";

        if (File.Exists(path))
        {
            BinaryFormatter formatter = new BinaryFormatter();
            FileStream      stream    = new FileStream(path, FileMode.Open);
            DataBaseMusic   data      = formatter.Deserialize(stream) as DataBaseMusic;
            stream.Close();
            return(data);
        }
        else
        {
            SaveMusic(0.7f, 0.7f);
            DataBaseMusic data = new DataBaseMusic(0.7f, 0.7f);
            return(data);
        }
    }