static void SmoothVUMeterData(ref float value, ref SmoothingData data, out float renderValue, out float renderPeak) { if (value <= data.lastValue) { value = Mathf.Lerp(data.lastValue, value, Time.smoothDeltaTime * 7.0f); } else { value = Mathf.Lerp(value, data.lastValue, Time.smoothDeltaTime * 2.0f); data.peakValue = value; data.peakValueTime = Time.realtimeSinceStartup; } if (value > 1.0f / VU_SPLIT) { value = 1.0f / VU_SPLIT; } if (data.peakValue > 1.0f / VU_SPLIT) { data.peakValue = 1.0f / VU_SPLIT; } renderValue = value * VU_SPLIT; renderPeak = data.peakValue * VU_SPLIT; data.lastValue = value; }
private static void SmoothVUMeterData(ref float value, ref SmoothingData data, out float renderValue, out float renderPeak) { if (value <= data.lastValue) { value = Mathf.Lerp(data.lastValue, value, Time.smoothDeltaTime * 7f); } else { value = Mathf.Lerp(value, data.lastValue, Time.smoothDeltaTime * 2f); data.peakValue = value; data.peakValueTime = Time.realtimeSinceStartup; } if (value > 1.11111116f) { value = 1.11111116f; } if (data.peakValue > 1.11111116f) { data.peakValue = 1.11111116f; } renderValue = value * 0.9f; renderPeak = data.peakValue * 0.9f; data.lastValue = value; }
// Auto smoothing version public static void VerticalMeter(Rect position, float value, ref SmoothingData data, Texture2D foregroundTexture, Color peakColor) { if (Event.current.type != EventType.Repaint) { return; } float renderValue, renderPeak; SmoothVUMeterData(ref value, ref data, out renderValue, out renderPeak); VerticalMeter(position, renderValue, renderPeak, foregroundTexture, peakColor); }
private static void HorizontalMeter(Rect position, float value, ref SmoothingData data, Texture2D foregroundTexture, Color peakColor) { if (Event.current.type != EventType.Repaint) { return; } float value2; float peak; SmoothVUMeterData(ref value, ref data, out value2, out peak); HorizontalMeter(position, value2, peak, foregroundTexture, peakColor); }
static public float LowPass( SmoothingData smoothingData ) { return smoothingData.value + ( smoothingData.target - smoothingData.value ) * smoothingData.strength; }
static public float Exponential( SmoothingData smoothingData ) { return smoothingData.value + ( smoothingData.target - smoothingData.value ) * 0.01f; }
private static void VUMeterHorizontal(float value, ref SmoothingData data, params GUILayoutOption[] options) { Rect position = EditorGUILayout.GetControlRect(false, 16f, EditorStyles.numberField, options); HorizontalMeter(position, value, ref data, HorizontalVUTexture, Color.grey); }
static public float LowPass(SmoothingData smoothingData) { return(smoothingData.value + (smoothingData.target - smoothingData.value) * smoothingData.strength); }
static public float Exponential(SmoothingData smoothingData) { return(smoothingData.value + (smoothingData.target - smoothingData.value) * 0.01f); }
public void GoTo( SmoothingData data, Func<SmoothingData, float> smoothingFunc ) { interpolating = true; smoothingData = data; smoothing = smoothingFunc; }
public void GoTo(SmoothingData data, Func <SmoothingData, float> smoothingFunc) { interpolating = true; smoothingData = data; smoothing = smoothingFunc; }