Exemplo n.º 1
0
 public void PlayMusic(PlayingMusicType type)
 {
     if ((MusicAudios.Length > 0) && (isMusicMuted == 0))
     {
         audioSrc.clip = MusicAudios[(int)type];
         audioSrc.loop = true;
         audioSrc.Play();
         musicType = type;
     }
 }
Exemplo n.º 2
0
 public void PlayMenuMusic()
 {
     if (musicType != PlayingMusicType.MENU)
     {
         if ((MusicAudios.Length > 0) && (isMusicMuted == 0))
         {
             audioSrc.clip = MusicAudios[(int)PlayingMusicType.MENU];
             audioSrc.loop = true;
             audioSrc.Play();
             musicType = PlayingMusicType.MENU;
         }
     }
 }
Exemplo n.º 3
0
    /// <summary>
    /// Toggle music state to On/Off
    /// </summary>
    public void ToggleMuteMusic()
    {
        if (isMusicMuted == 0)
        {
            musicType    = PlayingMusicType.NONE;
            isMusicMuted = 1;
            audioSrc.Stop();
        }
        else
        {
            isMusicMuted = 0;
            PlayMenuMusic();
        }

        // save the new music state
        PlayerSettings.SetMusicState(isMusicMuted);
    }
Exemplo n.º 4
0
    private float startingVol;         // store the starting volume of the audio source

    void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
        }
        else if (Instance != this)   // duplicate
        {
            Destroy(gameObject);

            throw new UnityException("Duplicate Game Manager!!");
        }

        DontDestroyOnLoad(gameObject);     // make it survive scene changes

        audioSrc  = GetComponent <AudioSource>();
        musicType = PlayingMusicType.NONE;

        // .. Get the previously saved music and sound effects states
        isMusicMuted        = PlayerSettings.GetMusicState();
        isSoundEffectsMuted = PlayerSettings.GetSoundEffectsState();

        startingVol = audioSrc.volume;
    }
Exemplo n.º 5
0
 /// <summary>
 /// Mute the audio source
 /// </summary>
 public void StopMusic()
 {
     musicType = PlayingMusicType.NONE;
     audioSrc.Stop();
 }