Exemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        FmodEventSystemHandle handle = new FmodEventSystemHandle();

        ReverbSettings.FmodReverbPreset globalReverbSetting = FmodReverb.GLOBAL_REVERB;
        m_globalReverb = FmodReverb.CreateInstance(typeof(FmodReverb)) as FmodReverb;
        GameObject obj = GameObject.Instantiate(Resources.Load("FmodReverbZone")) as GameObject;

        m_globalReverbZone = obj.GetComponent <FmodReverbZone>();

        if (m_globalReverbZone == null)
        {
            Debug.LogError("Prefab for FmodReverbZone should have component FmodReverbZone !");
        }
        m_globalReverbZone.SetGlobal(true);
        m_globalReverbZone.name = "Global Reverb";
        m_globalReverb.Initialize(globalReverbSetting.Name, globalReverbSetting.Properties);
        m_globalReverbZone.SetReverb(m_globalReverb);
        m_globalReverbZone.Priority = 0;
        m_globalReverbZone.fadeTime = 0;
        m_currentZone = m_globalReverbZone;
        StackReverb(m_currentZone);
        handle.getEventSystem().setReverbImmediate(globalReverbSetting.Properties);
        handle.Dispose();
        m_startProperties = globalReverbSetting.Properties;
        m_curProperties   = globalReverbSetting.Properties;
        m_endProperties   = globalReverbSetting.Properties;
    }
Exemplo n.º 2
0
    protected void loadReverbsFromFile(FmodEventAsset asset)
    {
        List <FmodReverb> reverbs = new List <FmodReverb>();

        FMOD.REVERB_PROPERTIES curReverb = new FMOD.REVERB_PROPERTIES();
        IntPtr curReverbName             = new IntPtr();
        string curReverbNameAsString;
        int    numReverbs = 0;

        FMOD.RESULT result    = FMOD.RESULT.OK;
        FmodReverb  newReverb = null;

        result = getEventSystem().getNumReverbPresets(ref numReverbs);
        ERRCHECK(result);
        if (result == FMOD.RESULT.OK)
        {
            for (int i = 0; i < numReverbs; i++)
            {
                result = getEventSystem().getReverbPresetByIndex(i, ref curReverb, ref curReverbName);
                ERRCHECK(result);
                if (result == FMOD.RESULT.OK)
                {
                    curReverbNameAsString = Marshal.PtrToStringAnsi(curReverbName);
                    newReverb             = ScriptableObject.CreateInstance(typeof(FmodReverb)) as FmodReverb;
                    newReverb.Initialize(curReverbNameAsString, curReverb);
                    reverbs.Add(newReverb);
                }
            }
        }
        asset.setReverbs(reverbs);
    }
Exemplo n.º 3
0
    public void UpdateGlobalReverb()
    {
        if (m_currentZone == m_globalReverbZone && m_globalReverbZone != null && m_globalReverb != null) {
            FmodEventSystemHandle handle = new FmodEventSystemHandle();
            ReverbSettings.FmodReverbPreset globalReverbSetting = ReverbSettings.Get().CurPreset;

            m_globalReverb = m_globalReverbZone.GetReverb();
            m_globalReverb.Initialize(globalReverbSetting.Name, globalReverbSetting.Properties);
            m_curProperties = m_globalReverb.getProperties();
            m_endProperties = m_curProperties;
            handle.getEventSystem().setReverbImmediate(m_curProperties);
            handle.Dispose();
        }
    }
Exemplo n.º 4
0
    public void UpdateGlobalReverb()
    {
        if (m_currentZone == m_globalReverbZone && m_globalReverbZone != null && m_globalReverb != null)
        {
            FmodEventSystemHandle           handle = new FmodEventSystemHandle();
            ReverbSettings.FmodReverbPreset globalReverbSetting = ReverbSettings.Get().CurPreset;

            m_globalReverb = m_globalReverbZone.GetReverb();
            m_globalReverb.Initialize(globalReverbSetting.Name, globalReverbSetting.Properties);
            m_curProperties = m_globalReverb.getProperties();
            m_endProperties = m_curProperties;
            handle.getEventSystem().setReverbImmediate(m_curProperties);
            handle.Dispose();
        }
    }
Exemplo n.º 5
0
    private void _updateReverbStack()
    {
        if (m_reverbStack.Count == 0)
        {
            return;
        }
        m_reverbStack.Sort((x, y) => (int)(y.Priority).CompareTo((int)x.Priority));
        FmodReverbZone newCurrentZone = m_reverbStack[0];


        if (m_currentZone != newCurrentZone)           // we should transition
        {
            float fadeInTime = newCurrentZone.fadeTime;

            // if we are transitionning from a zone back to the global zone, we use the previous fade time
            // to fade out
            if (newCurrentZone == m_globalReverbZone && m_currentZone != m_globalReverbZone)
            {
                m_globalReverb.Initialize(m_globalReverb.getName(), FmodReverb.GLOBAL_REVERB.Properties);
                fadeInTime = m_currentZone.fadeTime;
            }
            FMOD.REVERB_PROPERTIES targetProps = newCurrentZone.GetReverb().getProperties();
            if (fadeInTime <= 0)
            {
                FmodEventSystemHandle handle = new FmodEventSystemHandle();

                m_isInTransition  = false;
                m_startProperties = m_curProperties;
                m_endProperties   = targetProps;
                handle.getEventSystem().setReverbImmediate(targetProps);
                handle.Dispose();
            }
            else
            {
                m_isInTransition        = true;
                m_startProperties       = m_curProperties;
                m_endProperties         = targetProps;
                m_curTransitionDuration = fadeInTime;
                m_curTransitionTime     = 0;
            }
            m_currentZone = newCurrentZone;
        }
    }
Exemplo n.º 6
0
    // Use this for initialization
    void Start()
    {
        FmodEventSystemHandle handle = new FmodEventSystemHandle();
        ReverbSettings.FmodReverbPreset globalReverbSetting = FmodReverb.GLOBAL_REVERB;
        m_globalReverb = FmodReverb.CreateInstance(typeof(FmodReverb)) as FmodReverb;
        GameObject obj = GameObject.Instantiate(Resources.Load("FmodReverbZone")) as GameObject;
        m_globalReverbZone = obj.GetComponent<FmodReverbZone>();

        if (m_globalReverbZone == null) {
            Debug.LogError("Prefab for FmodReverbZone should have component FmodReverbZone !");
        }
        m_globalReverbZone.SetGlobal(true);
        m_globalReverbZone.name = "Global Reverb";
        m_globalReverb.Initialize(globalReverbSetting.Name, globalReverbSetting.Properties);
        m_globalReverbZone.SetReverb(m_globalReverb);
        m_globalReverbZone.Priority = 0;
        m_globalReverbZone.fadeTime = 0;
        m_currentZone = m_globalReverbZone;
        StackReverb (m_currentZone);
        handle.getEventSystem().setReverbImmediate(globalReverbSetting.Properties);
        handle.Dispose();
        m_startProperties = globalReverbSetting.Properties;
        m_curProperties = globalReverbSetting.Properties;
        m_endProperties = globalReverbSetting.Properties;
    }