コード例 #1
0
ファイル: SoundManager.cs プロジェクト: ttat/puzzlewarrior
    private void Awake()
    {
        if (Instance != null && Instance != this)
        {
            Destroy(this.gameObject);
        }

        Instance    = this;
        this.Paused = false;

        // Make sure music and sound fx is on by default if it's never been initialized
        if (!PlayerPrefsFast.HasKey(this.MusicOptionKey))
        {
            PlayerPrefsFast.SetBool(this.MusicOptionKey, true);
            PlayerPrefsFast.Flush();
        }

        if (!PlayerPrefsFast.HasKey(this.SoundOptionKey))
        {
            PlayerPrefsFast.SetBool(this.SoundOptionKey, true);
            PlayerPrefsFast.Flush();
        }

        this.CheckOptions();
        this.BackgroundMusicSource      = this.gameObject.AddComponent <AudioSource>();
        this.BackgroundMusicSource.loop = true;
        this.ContinuousSoundSource      = this.gameObject.AddComponent <AudioSource>();
        this.ContinuousSoundSource.loop = true;

        DontDestroyOnLoad(this.gameObject);
    }