/// <summary> /// Raises the volume of the associated group, lowers all others /// </summary> /// <param name="group"> group number to adjust volume of </param> void FocusMusic(int group) { if (group != -1 && group != volumeFocus) { volumeFocus = group; volState = VolState.Increasing; } else if (group == -1 && volumeFocus != -1) { volState = VolState.Decreasing; } }
void Update() { if (volState != VolState.None) { volume += Time.deltaTime * volumeRate; for (int x = 0; x < volumeLevels.Length; x++) { string paramName = volumeLevels[x]; if (x == volumeFocus) { if (volState == VolState.Increasing) { mixer.SetFloat(paramName, 0 + volume); } else if (volState == VolState.Decreasing) { mixer.SetFloat(paramName, volumeMax - volume); } } else if (x != volumeFocus) { if (volState == VolState.Increasing) { mixer.SetFloat(paramName, 0 - volume); } else if (volState == VolState.Decreasing) { mixer.SetFloat(paramName, (volumeMax * -1) + volume); } } } if (volume >= volumeMax) { volume = 0; if (volState == VolState.Decreasing) { volumeFocus = -1; } volState = VolState.None; } } if (matState == MatState.Increasing) { float val = glowMat.GetFloat("_node_3398"); if (val < MAT_MAX) { val += Time.deltaTime * MAT_RATE; glowMat.SetFloat("_node_3398", val); } else { matState = MatState.None; } } else if (matState == MatState.Decreasing) { float val = glowMat.GetFloat("_node_3398"); if (val > 0) { val -= Time.deltaTime * MAT_RATE; glowMat.SetFloat("_node_3398", val); } else { matState = MatState.None; } } }