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; }
/** * <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); }
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); }
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; }
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; }
// 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; }
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); }
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); }
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); }
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); } }
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); }
void Awake() { if (!initialized) { initialized = true; Title01 = musicTitle01; Game01 = music01; Game02 = music02; Game03 = music03; Game04 = music04; Snap1 = snap1; Snap2 = snap2; } }
public void TogglePausedSnapshot() { if (paused) { overworldSnapshot.TransitionTo(0.5f); paused = false; } else { storedSnapshot = currentSnapShot; pausedSnapshot.TransitionTo(0.25f); paused = true; } }
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; } } }
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>(); }
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); }
public void TransitionToOverworld() { AmbientTown.SetScheduledEndTime(10); if (DayNight.isDay) { overworldSnapshot.TransitionTo(10); currentSnapShot = overworldSnapshot; } else if (DayNight.isNight) { nightAmbientSnapshot.TransitionTo(10); currentSnapShot = nightAmbientSnapshot; } }
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); }
public void DecreaseAlertedEnemies() { if (enemiesAlerted == 1) { casualMusicSource.Play(); activeSnapshot = casualMusicSnapshot; casualMusicSnapshot.TransitionTo(0.5f); enemiesAlerted = 0; } else { enemiesAlerted--; } }
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); }
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; }
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"); }
private void SetSnapshot(AudioMixerSnapshot snap) { if (currentSnapshot == null) { currentSnapshot = snap; return; } if (snapshotPriority.ContainsKey(snap)) { if (snapshotPriority[snap] < snapshotPriority[currentSnapshot]) { currentSnapshot = snap; } } }
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(); }