Audio Support, Speed shift music, AudioProvider.Unk/Bunk
Also AudioHelper.SetVolume's
This commit is contained in:
parent
af9d68b631
commit
5c5a9d2993
|
@ -15,7 +15,9 @@ AudioMixerController:
|
|||
m_SuspendThreshold: -80
|
||||
m_EnableSuspend: 1
|
||||
m_UpdateMode: 0
|
||||
m_ExposedParameters: []
|
||||
m_ExposedParameters:
|
||||
- guid: 488bd2ac94838f14cadbca3c4455b0de
|
||||
name: ShiftPitch
|
||||
m_AudioMixerGroupViews:
|
||||
- guids:
|
||||
- 566c5e0ddf85965418c4e928780bd1c2
|
||||
|
@ -65,7 +67,8 @@ AudioMixerSnapshotController:
|
|||
m_Name: Snapshot
|
||||
m_AudioMixer: {fileID: 24100000}
|
||||
m_SnapshotID: 4117f6b7fd784794ba09e4c024f88699
|
||||
m_FloatValues: {}
|
||||
m_FloatValues:
|
||||
488bd2ac94838f14cadbca3c4455b0de: 1
|
||||
m_TransitionOverrides: {}
|
||||
--- !u!244 &2747661610774394998
|
||||
AudioMixerEffectController:
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using UnityEngine.Audio;
|
||||
|
||||
using EntityNetwork;
|
||||
|
||||
public class AudioProvider : EntityBase, IAutoRegister
|
||||
|
@ -12,14 +14,48 @@ public class AudioProvider : EntityBase, IAutoRegister
|
|||
Instance = this;
|
||||
|
||||
bgmSrc = GetComponent<AudioSource>();
|
||||
|
||||
UnkClip = Resources.Load<AudioClip>("Unk");
|
||||
BunkClip = Resources.Load<AudioClip>("Bunk");
|
||||
}
|
||||
|
||||
public float musicSpeed = 1f;
|
||||
AudioSource bgmSrc;
|
||||
|
||||
public bool fastBGM = false;
|
||||
|
||||
[ContextMenu("Speedup Music for 5s")]
|
||||
public void SpeedupForFiveSeconds() {
|
||||
Instance.fastBGM = true;
|
||||
timeUntilSlow = Time.time + 5f;
|
||||
}
|
||||
|
||||
public static float timeUntilSlow = 0f;
|
||||
public static void RequestFastMusic() {
|
||||
Instance.fastBGM = true;
|
||||
timeUntilSlow = Time.time + 3f;
|
||||
}
|
||||
|
||||
static AudioClip UnkClip, BunkClip;
|
||||
|
||||
public static void Unk() {
|
||||
PlaySFX(UnkClip, AudioHelper.AudioCategory.Fx);
|
||||
}
|
||||
|
||||
public static void Bunk() {
|
||||
PlaySFX(BunkClip, AudioHelper.AudioCategory.Fx);
|
||||
}
|
||||
|
||||
public void Update() {
|
||||
// TODO - This is WIP help
|
||||
//bgmSrc.outputAudioMixerGroup.
|
||||
bgmSrc.loop = true;
|
||||
|
||||
bgmSrc.volume = AudioHelper.VolumeLevel(AudioHelper.AudioCategory.Music);
|
||||
|
||||
bgmSrc.pitch = fastBGM ? 1.3333f : 1f;
|
||||
bgmSrc.outputAudioMixerGroup.audioMixer.SetFloat("ShiftPitch", fastBGM ? 0.75f : 1f);
|
||||
|
||||
if (Time.time > timeUntilSlow)
|
||||
fastBGM = false;
|
||||
}
|
||||
|
||||
int lastAudioFrame = 0;
|
||||
|
|
Loading…
Reference in New Issue