Fade() public method

If the audio source is enabled and playing, fades out the current clip and fades in the specified one, after. If the audio source is enabled and not playing, fades in the specified clip immediately. If the audio source is not enalbed, fades in the specified clip as soon as it gets enabled.
public Fade ( AudioClip clip, float volume, bool loop ) : void
clip UnityEngine.AudioClip Clip to fade in.
volume float Volume to fade to.
loop bool Whether to loop the new clip, or not.
return void
    public void PlayPlaceMusic(EnvironmentManager.Place place)
    {
        switch (place)
        {
        case EnvironmentManager.Place.Title_Screen:
            backgroundMusic.Fade(titleMusic, MAX_VOLUME, true);

            //start the kitchen background noises
            foley.ToggleSound(OnOrOff.On);
            foley.Fade(kitchenBackgroundSFX, MAX_VOLUME, true);
            break;

        case EnvironmentManager.Place.Kitchen:
            backgroundMusic.Fade(kitchenMusic, MAX_VOLUME, true);

            //start the kitchen background noises
            foley.ToggleSound(OnOrOff.On);
            foley.Fade(kitchenBackgroundSFX, MAX_VOLUME, true);
            break;

        case EnvironmentManager.Place.Tavern:
            backgroundMusic.Fade(tavernMusic, MAX_VOLUME, true);
            foley.Fade(tavernBackgroundSFX, MAX_VOLUME, true);
            break;

        case EnvironmentManager.Place.Battlefield:

            //start the sword-clashing background sound
            foley.Fade(battleBackgroundSFX, MAX_VOLUME, true);
            break;
        }

        currentMusic = backgroundMusic.GetCurrentClip();
    }
示例#2
0
 public void InitBoss()
 {
     bossBattle = true;
     rescueObjective.transform.parent.gameObject.SetActive(false);
     lootObjective.transform.parent.gameObject.SetActive(false);
     musicSource.Fade(bossMusic, 0.4f, true);
 }
示例#3
0
    // Update is called once per frame
    void Update()
    {
        for (int i = currentWaveUnits.Count - 1; i >= 0; i--)
        {
            Prototype_Nav enemy = currentWaveUnits[i];
            if (enemy == null)
            {
                currentWaveUnits.RemoveAt(i);
                continue;
            }

            //LIFE ALWAYS BEING LOST IMMEDIATELY IF FIRST ARGUMENT IS GONE
            if (enemy.Agent.remainingDistance != 0 && enemy.Agent.remainingDistance < .1f)
            {
                waveLeft--;
                currentWaveUnits.RemoveAt(i);
            }
        }

        if (!shopPlaying && waveLeft == 0)
        {
            EndWave();
            shopPlaying = true;
            music.Fade(shopMusic, 1f, true);
        }
    }
示例#4
0
    // Use this for initialization
    void Start()
    {
        normalClip   = (AudioClip)Resources.Load(StringAssets.bgmPath + "Normal", typeof(AudioClip));
        fightClip    = new AudioClip[2];
        fightClip[0] = (AudioClip)Resources.Load(StringAssets.bgmPath + "Fight1", typeof(AudioClip));
        fightClip[1] = (AudioClip)Resources.Load(StringAssets.bgmPath + "Fight2", typeof(AudioClip));

        fadingAudioSource.Fade(normalClip, bgmVolum, true);
    }
示例#5
0
 // Use this for initialization
 void Start()
 {
     music       = GameObject.Find("Music Audio Source").GetComponent <FadingAudioSource> ();
     lives_track = gameObject.GetComponent <Lives_Tracker>();
     shopPlaying = false;
     music.Fade(shopMusic, 1f, true);
     currentWaveUnits = new List <Prototype_Nav>();
     //StartCoroutine(StartWave());
 }
示例#6
0
 // Use this for initialization
 void Start()
 {
     music = gameObject.GetComponent <FadingAudioSource> ();
     music.Fade(shopMusic, 1f, true);
 }