// Draw the input level bar. void DrawLevelBar(VJAbstractAudioJackDataSource ds) { if (barTextures == null) { // Make textures for drawing level bars. barTextures = new Texture2D[] { NewBarTexture(Color.red), NewBarTexture(Color.green), NewBarTexture(Color.blue), NewBarTexture(Color.gray) }; } // Peak level label. EditorGUILayout.LabelField("Peak Level", ds.Peak.ToString("0.0") + " dB"); // Get a rectangle as a text field. var rect = GUILayoutUtility.GetRect(18, 10, "TextField"); var width = rect.width; // Fill the rectangle with gray. GUI.DrawTexture(rect, barTextures [3]); // Draw the range bar with red. rect.x += width * (ds.Peak - ds.lowerBound - ds.dynamicRange - ds.headroom) / (3 - ds.lowerBound); rect.width = width * (ds.dynamicRange + ds.headroom) / (3 - ds.lowerBound); GUI.DrawTexture(rect, barTextures [0]); // Draw the effective range bar with green. rect.width = width * (ds.dynamicRange) / (3 - ds.lowerBound); GUI.DrawTexture(rect, barTextures [1]); // Draw the output level bar with blue. rect.width = width * ds.dynamicRange * ds.Output / (3 - ds.lowerBound); rect.y += rect.height / 2; rect.height /= 2; GUI.DrawTexture(rect, barTextures [2]); }
// Draw the input level bar. void DrawLevelBar(VJAbstractAudioJackDataSource ds) { if (barTextures == null) { // Make textures for drawing level bars. barTextures = new Texture2D[] { NewBarTexture (Color.red), NewBarTexture (Color.green), NewBarTexture (Color.blue), NewBarTexture (Color.gray) }; } // Peak level label. EditorGUILayout.LabelField ("Peak Level", ds.Peak.ToString ("0.0") + " dB"); // Get a rectangle as a text field. var rect = GUILayoutUtility.GetRect (18, 10, "TextField"); var width = rect.width; // Fill the rectangle with gray. GUI.DrawTexture (rect, barTextures [3]); // Draw the range bar with red. rect.x += width * (ds.Peak - ds.lowerBound - ds.dynamicRange - ds.headroom) / (3 - ds.lowerBound); rect.width = width * (ds.dynamicRange + ds.headroom) / (3 - ds.lowerBound); GUI.DrawTexture (rect, barTextures [0]); // Draw the effective range bar with green. rect.width = width * (ds.dynamicRange) / (3 - ds.lowerBound); GUI.DrawTexture (rect, barTextures [1]); // Draw the output level bar with blue. rect.width = width * ds.dynamicRange * ds.Output / (3 - ds.lowerBound); rect.y += rect.height / 2; rect.height /= 2; GUI.DrawTexture (rect, barTextures [2]); }