summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/FMOD/XFmodBus.cs
blob: b582ac6c252291764641398a5daf6a61799dac5d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
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;
    }
}