Exemplo n.º 1
0
    public void TransitionAudio(string amsToName, float timeForTransition, float weight = 1.0f)
    {
        AudioMixerSnapshot ams = audioMixer.FindSnapshot(amsToName);

        AudioMixerSnapshot[] amsArray = new AudioMixerSnapshot[] { ams };
        float[] weightArray           = new float[] { weight };

        audioMixer.TransitionToSnapshots(amsArray, weightArray, timeForTransition);
        currentAudioMixerSnapshot = ams.name;
    }
Exemplo n.º 2
0
        /**
         * <summary>Creates a new instance of the 'Sound: Set Mixer snapshot' Action, set to play a single snapshot</summary>
         * <param name = "snapshot">The snapshot to play</param>
         * <param name = "transitionTime">The time, in seconds, to take when transitioning</param>
         * <param name = "waitUntilFinish">If True, then the Action will wait until the transition is complete</param>
         * <returns>The generated Action</returns>
         */
        public static ActionMixerSnapshot CreateNew_Single(AudioMixerSnapshot snapshot, float transitionTime = 0f, bool waitUntilFinish = false)
        {
            ActionMixerSnapshot newAction = (ActionMixerSnapshot)CreateInstance <ActionMixerSnapshot>();

            newAction.numSnapshots = 1;
            newAction.snapshot     = snapshot;
            newAction.changeTime   = transitionTime;
            newAction.willWait     = waitUntilFinish;
            return(newAction);
        }
Exemplo n.º 3
0
    public void SnapshotTransition(string name, float value)
    {
        AudioMixerSnapshot s = mixer.FindSnapshot(name);

        if (s == null)
        {
            Debug.LogWarning("Snapshot: " + name + " not found");
            return;
        }
        s.TransitionTo(value);
    }
 bool CheckIfHasIntermediate(AudioMixerSnapshot snapshot)
 {
     foreach (AudioMixerSnapshot snap in snapshots)
     {
         if (snap.name.Contains(snapshot.name) && snap.name != snapshot.name)
         {
             return(true);
         }
     }
     return(false);
 }
 AudioMixerSnapshot GetIntermediate(AudioMixerSnapshot snapshot)
 {
     foreach (AudioMixerSnapshot snap in snapshots)
     {
         if (snap.name.Contains(snapshot.name) && snap.name != snapshot.name)
         {
             return(snap);
         }
     }
     return(null);
 }
Exemplo n.º 6
0
        IEnumerator ApplyMusicSnapshotRoutine(AudioMixerSnapshot snapshot, float delayTime, float transitionTime)
        {
            yield return(new WaitForSeconds(delayTime));

            //WeaverLog.Log("Snapshot = " + snapshot);
            if (snapshot != null)
            {
                snapshot.TransitionTo(transitionTime);
            }
            ApplySnapshotRoutine = null;
        }
Exemplo n.º 7
0
    public void Initialize()
    {
        healthRender  = healthGO.GetComponent <Renderer>();
        redLowLife    = Color.red;
        redMediumLife = redLowLife;
        greenHighLife = Color.green;
        lowSnap       = SFX.FindSnapshot("LowHealth");
        normalSnap    = master.FindSnapshot("Snapshot");

        firstEnter = true;
    }
Exemplo n.º 8
0
    // Update is called once per frame
    void Update()
    {
        if (!Input.GetKeyUp(KeyCode.Escape))
        {
            return;
        }
        this._isPaused = !this._isPaused;
        AudioMixerSnapshot snapshotTo = this._isPaused ? this._pausedSnapshot : this._unpausedSnapshot;

        snapshotTo.TransitionTo(0f);
        Time.timeScale = this._isPaused ? 0 : 1;
    }
Exemplo n.º 9
0
        public static void ApplyMusicSnapshot(AudioMixerSnapshot snapshot, float delayTime, float transitionTime)
        {
            AudioMixer_I.Instance.ApplyMusicSnapshot(snapshot, delayTime, transitionTime);

            /*if (ApplySnapshotRoutine != null)
             * {
             *      StopCoroutine(ApplySnapshotRoutine);
             *      ApplySnapshotRoutine = null;
             * }
             *
             * ApplySnapshotRoutine = StartCoroutine(ApplyMusicSnapshotRoutine(snapshot, delayTime, transitionTime));*/
        }
    void Start()
    {
        _audioSources = GetComponents <AudioSource>();

        main   = mixer.FindSnapshot("Main");
        nature = mixer.FindSnapshot("Nature");
        bad    = mixer.FindSnapshot("Bad");
        civ    = mixer.FindSnapshot("Civ");

        mixer.updateMode = AudioMixerUpdateMode.Normal;
        bad.TransitionTo(timeToReach);
    }
Exemplo n.º 11
0
    IEnumerator FinalFade(AudioMixerSnapshot snapshot)
    {
        yield return(new WaitForSeconds(timeToHold));

        AudioMixerSnapshot[] input = new AudioMixerSnapshot[1];
        input[0] = snapshot;
        float[] weights = new float[1] {
            1
        };

        snapshot.audioMixer.TransitionToSnapshots(input, weights, time_IntermediateToNew);
    }
    // INTERNALS

    private bool AddToQueue(AudioMixerSnapshot i_Snapshot, float i_FadeTime, double i_Priority)
    {
        if (i_Snapshot == null)
        {
            return(false);
        }

        AudioMixerSnapshotData newSnapshot = new AudioMixerSnapshotData(i_Snapshot, i_FadeTime);

        m_Queue.Enqueue(newSnapshot, i_Priority);
        return(true);
    }
Exemplo n.º 13
0
    EventStatus IEventListener.Process(Fabric.Event zEvent)
    {
        if (_audioMixers.Count == 0)
        {
            return(EventStatus.Not_Handled);
        }
        switch (zEvent.EventAction)
        {
        case EventAction.LoadAudioMixer:
        {
            UnityEngine.Audio.AudioMixer audioMixer3 = Resources.Load((string)zEvent._parameter) as UnityEngine.Audio.AudioMixer;
            if (audioMixer3 != null)
            {
                _audioMixers.Add(audioMixer3);
            }
            break;
        }

        case EventAction.UnloadAudioMixer:
        {
            UnityEngine.Audio.AudioMixer audioMixer2 = _audioMixers.Find((UnityEngine.Audio.AudioMixer x) => x.name.Contains((string)zEvent._parameter));
            if (audioMixer2 != null)
            {
                _audioMixers.Remove(audioMixer2);
                Resources.UnloadAsset(audioMixer2);
            }
            break;
        }

        case EventAction.TransitionToSnapshot:
        {
            TransitionToSnapshotData transitionToSnapshotData = (TransitionToSnapshotData)zEvent._parameter;
            if (transitionToSnapshotData == null)
            {
                break;
            }
            for (int i = 0; i < _audioMixers.Count; i++)
            {
                UnityEngine.Audio.AudioMixer audioMixer = _audioMixers[i];
                if (audioMixer != null)
                {
                    AudioMixerSnapshot audioMixerSnapshot = audioMixer.FindSnapshot(transitionToSnapshotData._snapshot);
                    if (audioMixerSnapshot != null)
                    {
                        audioMixerSnapshot.TransitionTo(transitionToSnapshotData._timeToReach);
                    }
                }
            }
            break;
        }
        }
        return(EventStatus.Handled);
    }
    private bool RemoveFromQueue(AudioMixerSnapshot i_Snapshot)
    {
        AudioMixerSnapshotData snapshotData = GetDataFromQueue(i_Snapshot);

        if (snapshotData == null)
        {
            return(false);
        }

        m_Queue.Remove(snapshotData);
        return(true);
    }
Exemplo n.º 15
0
 public void SetSnapshot(AudioMixerSnapshotGame snapshot, float time_to_reach = 0.5f)
 {
     if (snapshot == this.m_CurrentSnapshot)
     {
         return;
     }
     AudioMixerSnapshot[] array = null;
     float[] array2             = null;
     if (snapshot == AudioMixerSnapshotGame.Default)
     {
         array     = new AudioMixerSnapshot[2];
         array2    = new float[2];
         array[0]  = this.m_SnapshotDefault;
         array2[0] = 1f;
         array[1]  = this.m_SnapshotLowSanity;
         array2[1] = 0f;
     }
     else if (snapshot == AudioMixerSnapshotGame.LowSanity)
     {
         array     = new AudioMixerSnapshot[2];
         array2    = new float[2];
         array[0]  = this.m_SnapshotDefault;
         array2[0] = 0f;
         array[1]  = this.m_SnapshotLowSanity;
         array2[1] = 1f;
     }
     else if (snapshot == AudioMixerSnapshotGame.Sleep)
     {
         array     = new AudioMixerSnapshot[2];
         array2    = new float[2];
         array[0]  = this.m_SnapshotDefault;
         array2[0] = 0f;
         array[1]  = this.m_SnapshotSleep;
         array2[1] = 1f;
     }
     else if (snapshot == AudioMixerSnapshotGame.Underwater)
     {
         array     = new AudioMixerSnapshot[2];
         array2    = new float[2];
         array[0]  = this.m_SnapshotDefault;
         array2[0] = 0f;
         array[1]  = this.m_SnapshotUnderwater;
         array2[1] = 1f;
     }
     this.m_AudioMixer.TransitionToSnapshots(array, array2, time_to_reach);
     GreenHellGame.OnAudioSnapshotChangedDel onAudioSnapshotChangedEvent = this.OnAudioSnapshotChangedEvent;
     if (onAudioSnapshotChangedEvent != null)
     {
         onAudioSnapshotChangedEvent(this.m_CurrentSnapshot, snapshot);
     }
     this.m_CurrentSnapshot = snapshot;
 }
 void MixerFadeThroughIntermediate(AudioMixerSnapshot snapshot)
 {
     if (CheckIfHasIntermediate(snapshot))
     {
         MixerFadeToSnapshot(GetIntermediate(snapshot));
         fadeAfterIntermedate = FinalFade(snapshot);
         StartCoroutine(fadeAfterIntermedate);
     }
     else
     {
         MixerFadeToSnapshot(snapshot);
     }
 }
Exemplo n.º 17
0
 void Awake()
 {
     DontDestroyOnLoad(this.gameObject);
     masterGroup     = audioMixer.FindMatchingGroups("Master")[0];
     musicGroup      = audioMixer.FindMatchingGroups("Music")[0];
     sfxGroup        = audioMixer.FindMatchingGroups("Sfx")[0];
     worldGroup      = audioMixer.FindMatchingGroups("World")[0];
     uiGroup         = audioMixer.FindMatchingGroups("Ui")[0];
     indoorSnapshot  = audioMixer.FindSnapshot("Indoor");
     outdoorSnapshot = audioMixer.FindSnapshot("Outdoor");
     audioMixer.GetFloat("MasterVol", out maxMasterVol);
     audioMixer.GetFloat("MusicVol", out maxMusicVol);
 }
Exemplo n.º 18
0
 void Awake()
 {
     if (!initialized)
     {
         initialized = true;
         Title01     = musicTitle01;
         Game01      = music01;
         Game02      = music02;
         Game03      = music03;
         Game04      = music04;
         Snap1       = snap1;
         Snap2       = snap2;
     }
 }
Exemplo n.º 19
0
 public void TogglePausedSnapshot()
 {
     if (paused)
     {
         overworldSnapshot.TransitionTo(0.5f);
         paused = false;
     }
     else
     {
         storedSnapshot = currentSnapShot;
         pausedSnapshot.TransitionTo(0.25f);
         paused = true;
     }
 }
Exemplo n.º 20
0
 public void TransitionTo(string snapshotName, float transitionTime = 1f)
 {
     //IL_0019: Unknown result type (might be due to invalid IL or missing references)
     //IL_001e: Expected O, but got Unknown
     if (!(audioMixer == null))
     {
         AudioMixerSnapshot val = audioMixer.FindSnapshot(snapshotName);
         if (!(val == null) && !(mixerCurrent == val))
         {
             val.TransitionTo(transitionTime);
             mixerCurrent = val;
         }
     }
 }
Exemplo n.º 21
0
        private void Awake()
        {
            pause    = audioMixer.FindSnapshot("Pause");
            notPause = audioMixer.FindSnapshot("UnPause");

            containers = new Dictionary <string, AudioContainer>
            {
                { "musicVolume", new AudioContainer("musicVolume") },
                { "soundEffectVolume", new AudioContainer("soundEffectVolume") },
                { "masterVolume", new AudioContainer("masterVolume") }
            };

            activeContainer = new List <AudioContainer>();
        }
Exemplo n.º 22
0
 void MixerFadeToSnapshot(AudioMixerSnapshot snapshot)
 {
     AudioMixerSnapshot[] input = new AudioMixerSnapshot[2];
     input[0] = snapshot;
     input[1] = currentSnapshot;
     float[] weights = new float[2] {
         weight_NewAtIntermediate, weight_OldAtIntermediate
     };
     //Debug.Log("current: " + currentSnapshot+ "   new: " + snapshot + " weights: " + weights[0]+"  "+ weights[1]);
     snapshot.audioMixer.TransitionToSnapshots(input, weights, time_OldToIntermediate);
     currentSnapshot      = snapshot;
     fadeAfterIntermedate = FinalFade(snapshot);
     StartCoroutine(fadeAfterIntermedate);
 }
Exemplo n.º 23
0
 public void TransitionToOverworld()
 {
     AmbientTown.SetScheduledEndTime(10);
     if (DayNight.isDay)
     {
         overworldSnapshot.TransitionTo(10);
         currentSnapShot = overworldSnapshot;
     }
     else if (DayNight.isNight)
     {
         nightAmbientSnapshot.TransitionTo(10);
         currentSnapShot = nightAmbientSnapshot;
     }
 }
Exemplo n.º 24
0
        void Awake()
        {
            mainSnapshot  = m_AudioMixer.FindSnapshot("Overworld");
            eventSnapshot = m_AudioMixer.FindSnapshot("InEvent");

            foreach (var canvasGroup in m_CanvasGroups)
            {
                canvasGroup.alpha          = 0;
                canvasGroup.blocksRaycasts = false;
                canvasGroup.interactable   = false;
            }

            SealButton.onClick.AddListener(OnSealButtonClicked);
        }
Exemplo n.º 25
0
 public void DecreaseAlertedEnemies()
 {
     if (enemiesAlerted == 1)
     {
         casualMusicSource.Play();
         activeSnapshot = casualMusicSnapshot;
         casualMusicSnapshot.TransitionTo(0.5f);
         enemiesAlerted = 0;
     }
     else
     {
         enemiesAlerted--;
     }
 }
Exemplo n.º 26
0
    private void Start()
    {
        DontDestroyOnLoad(this.gameObject);

        PlayerController.OnItemPlacedInFoyer += OnItemPlacedInFoyer;

        nothingSnapshot = mixer.FindSnapshot("Nothing");
        theme1Snapshot  = mixer.FindSnapshot("Theme1Playing");
        theme2Snapshot  = mixer.FindSnapshot("Theme2Playing");
        theme3Snapshot  = mixer.FindSnapshot("Theme3Playing");
        theme4Snapshot  = mixer.FindSnapshot("Theme4Playing");
        theme5Snapshot  = mixer.FindSnapshot("Theme5Playing");

        OnItemPlacedInFoyer(null);
    }
Exemplo n.º 27
0
    public IEnumerator PlayEventMusic()
    {
        eventRunning = true;
        eventSnap.TransitionTo(0.25f);
        currentAudioMixerSnapshot = eventSnap;
        yield return(new WaitForSeconds(0.3f));

        eventMusic.Play();
        while (eventMusic.isPlaying)
        {
            yield return(null);
        }
        eventRunning = false;
        idleSnapshot.TransitionTo(0.5f);
        yield break;
    }
Exemplo n.º 28
0
    private void Start()
    {
        //startSnapshot = mixer.FindSnapshot("Start");
        //musicSnapshot = mixer.FindSnapshot("Music");
        masterSnapshot = mixer.FindSnapshot("Master");

        //Play("draw_sound");
        // Play("death_sound");
        // Play("ball_in_well");
        // Play("ball_shoot");
        // Play("pool_crash");
        // Play("delete_drawing");
        // Play("flame_lit");
        // Play("pool_spawned");
        // Play("checkpoint");
    }
Exemplo n.º 29
0
    private void SetSnapshot(AudioMixerSnapshot snap)
    {
        if (currentSnapshot == null)
        {
            currentSnapshot = snap;
            return;
        }

        if (snapshotPriority.ContainsKey(snap))
        {
            if (snapshotPriority[snap] < snapshotPriority[currentSnapshot])
            {
                currentSnapshot = snap;
            }
        }
    }
Exemplo n.º 30
0
    private void Start()
    {
        _aNoLowpass = mixer.FindSnapshot("A_NoLowpass");
        _aLowpass   = mixer.FindSnapshot("A_Lowpass");
        _bNoLowpass = mixer.FindSnapshot("B_NoLowpass");
        _bLowpass   = mixer.FindSnapshot("B_Lowpass");
        _cNoLowpass = mixer.FindSnapshot("C_NoLowpass");
        _cLowpass   = mixer.FindSnapshot("C_Lowpass");
        _dNoLowpass = mixer.FindSnapshot("D_NoLowpass");
        _dLowpass   = mixer.FindSnapshot("D_Lowpass");

        track1.Play();
        track2.Play();
        track3.Play();
        track4.Play();
    }