//get volume of param, accounting for substitutions public float GetVolume(FMOD_StudioEventEmitter ev) { float paramVal = 0.0f; FMOD.Studio.ParameterInstance param = ev.getParameter(GetCurParam()); if (param != null) param.getValue(out paramVal); return paramVal; }
//set volume of param, accounting for substitutions that may need to happen public void SetVolume(float vol, FMOD_StudioEventEmitter ev) { //if we have substitutions, just silence all at first so we don't leave any tracks on accidently if (Substitutions.Length > 0) SilenceAll(ev); FMOD.Studio.ParameterInstance param = ev.getParameter(GetCurParam()); if (param != null) { param.setValue(Mathf.Lerp(0.0f, MixVolume, vol)); } }
//the start access and saves a few "pointers" to the necessary scrips and variables //(this is to provide shortcuts to what we want to access and/or change) void Start(){ try{ m_Emitter = gameObject.GetComponent<FMOD_StudioEventEmitter> (); }catch{ Debug.LogWarning("No Emitter attached to this object, i guess i have to do EVERYTHING myself"); //AttachFmodEmitter(); } surfaceTexture = gameObject.GetComponent<GetDominantTexture> (); if(m_Parameter == null){ try{ m_Parameter = m_Emitter.getParameter("Surface"); } catch { Debug.LogWarning("FMOD parameter failed, will try again"); //TryGetParameterAgain(); } } }
void SilenceAll(FMOD_StudioEventEmitter ev) { FMOD.Studio.ParameterInstance param = ev.getParameter(FModParamName); if (param != null) param.setValue(0.0f); for (int i = 0; i < Substitutions.Length; i++) { FMOD.Studio.ParameterInstance sParm = ev.getParameter(Substitutions[i].SubstituteParamName); if (sParm != null) sParm.setValue(0.0f); } }