diff options
author | chai <chaifix@163.com> | 2021-01-25 14:28:30 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-01-25 14:28:30 +0800 |
commit | 6eb915c129fc90c6f4c82ae097dd6ffad5239efc (patch) | |
tree | 7dd2be50edf41f36b60fac84696e731c13afe617 /Client/Assets/Scripts/FMOD/XFmodBus.cs |
+scripts
Diffstat (limited to 'Client/Assets/Scripts/FMOD/XFmodBus.cs')
-rw-r--r-- | Client/Assets/Scripts/FMOD/XFmodBus.cs | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/Client/Assets/Scripts/FMOD/XFmodBus.cs b/Client/Assets/Scripts/FMOD/XFmodBus.cs new file mode 100644 index 00000000..b582ac6c --- /dev/null +++ b/Client/Assets/Scripts/FMOD/XFmodBus.cs @@ -0,0 +1,97 @@ +using UnityEngine;
+using XUtliPoolLib;
+
+public class XFmodBus : MonoBehaviour, IXFmodBus
+{
+ FMOD.Studio.Bus bus;
+ FMOD.Studio.VCA mainVCA;
+ FMOD.Studio.VCA bgmVCA;
+ FMOD.Studio.VCA sfxVCA;
+ FMODUnity.StudioEventEmitter e;
+
+ //public void SetMute(bool mute)
+ //{
+ // GetBus();
+ // bus.setMute(mute);
+ //}
+
+ public void SetBusVolume(string strBus, float volume)
+ {
+ FMOD.Studio.Bus bus;
+ FMODUnity.RuntimeManager.StudioSystem.getBus(strBus, out bus);
+
+ if (bus != null) bus.setVolume(volume);
+ }
+
+ //public void SetFaderLevel(float volume)
+ //{
+ // GetBus();
+ // bus.setFaderLevel(volume);
+ //}
+
+ //public float GetFaderLevel()
+ //{
+ // GetBus();
+ // float f = 0;
+ // bus.getFaderLevel(out f);
+ // return f;
+ //}
+
+ //protected void GetBus()
+ //{
+ // if (bus == null)
+ // bus = FMOD_StudioSystem.instance.GetBus("bus:/");
+ //}
+
+ public void SetMainVolume(float volume)
+ {
+ if (mainVCA == null)
+ FMODUnity.RuntimeManager.StudioSystem.getVCA("vca:/Main Volume Control", out mainVCA);
+
+ if (mainVCA != null) mainVCA.setVolume(volume);
+ }
+
+ public void SetBGMVolume(float volume)
+ {
+ if (bgmVCA == null)
+ FMODUnity.RuntimeManager.StudioSystem.getVCA("vca:/BGM Volume Control", out bgmVCA);
+
+ if (bgmVCA != null) bgmVCA.setVolume(volume);
+ }
+
+ public void SetSFXVolume(float volume)
+ {
+ if (sfxVCA == null)
+ FMODUnity.RuntimeManager.StudioSystem.getVCA("vca:/SFX Volume Control", out sfxVCA);
+
+ if (sfxVCA != null) sfxVCA.setVolume(volume);
+ }
+
+ public void PlayOneShot(string key, Vector3 pos)
+ {
+ FMODUnity.RuntimeManager.PlayOneShot(key, pos);
+ }
+
+ public void StartEvent(string key)
+ {
+ if (e == null)
+ e = gameObject.AddComponent<FMODUnity.StudioEventEmitter>();
+
+ e.Event = key;
+ e.CacheEventInstance();
+ e.Play();
+ }
+
+ public void StopEvent()
+ {
+ if (e == null) return;
+
+ e.Stop();
+ }
+
+ public bool Deprecated
+ {
+ get;
+ set;
+ }
+}
|