public TreeItem(SECTR_AudioWindow window, SECTR_AudioBus bus, string path) { this.bus = bus; this.path = path; this.Name = bus.name; this.Expanded = EditorPrefs.GetBool(expandedPrefPrefix + this.path, true); window.hierarchyItems.Add(AsObject, this); }
public static void DrawBusControls(string name, float width, SECTR_AudioBus Bus, Texture muteOnIcon, Texture muteOffIcon, Texture soloOnIcon, Texture soloOffIcon, GUIStyle elementStyle, GUIStyle busSliderStyle, GUIStyle busFieldStyle) { EditorGUILayout.BeginVertical(GUILayout.Width(width)); // Bus Block if(!string.IsNullOrEmpty(name)) { elementStyle.normal.textColor = SECTR_Window.UnselectedItemColor; elementStyle.alignment = TextAnchor.MiddleCenter; elementStyle.fontStyle = FontStyle.Bold; GUILayout.Label(name, elementStyle); elementStyle.fontStyle = FontStyle.Normal; } else { EditorGUILayout.Space(); } EditorGUILayout.BeginHorizontal(); // Solo and Mute buttons bool busMuted = Bus.Muted; if(GUILayout.Button(new GUIContent(busMuted ? muteOnIcon : muteOffIcon, "Changes mute state of this bus."), elementStyle)) { SECTR_Undo.Record(Bus, "Muted Bus"); Bus.Muted = !busMuted; EditorUtility.SetDirty(Bus); } bool busSoloed = SECTR_AudioSystem.BusIsSolo(Bus); if(GUILayout.Button(new GUIContent(busSoloed ? soloOnIcon : soloOffIcon, "Only sounds played through this bus will be audible."), elementStyle)) { SECTR_Undo.Record(Bus, "Solod Bus"); SECTR_AudioSystem.Solo(Bus, !busSoloed); EditorUtility.SetDirty(Bus); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); // Sliders // Volume Slider EditorGUILayout.BeginVertical(); // Start Volume EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); float oldVolume = Bus.Volume; float newVolume = GUILayout.VerticalSlider(oldVolume, 1, 0, busSliderStyle, GUI.skin.verticalSliderThumb); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); // Volume Field EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); newVolume = EditorGUILayout.FloatField(newVolume, busFieldStyle, GUILayout.Width(50)); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); // Volume Label GUILayout.Label("Volume", elementStyle); EditorGUILayout.EndHorizontal(); // End Volume // Pitch Slider EditorGUILayout.BeginVertical(); // Start Volume EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); float oldPitch = Bus.Pitch; float newPitch = GUILayout.VerticalSlider(oldPitch, 2, 0, busSliderStyle, GUI.skin.verticalSliderThumb); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); // Pitch Field EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); newPitch = EditorGUILayout.FloatField(newPitch, busFieldStyle, GUILayout.Width(50)); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); // Pitch Label GUILayout.Label("Pitch", elementStyle); EditorGUILayout.EndHorizontal(); // End Pitch EditorGUILayout.EndVertical(); // End Sliders EditorGUILayout.EndVertical(); // End Bus if(oldVolume != newVolume || oldPitch != newPitch) { SECTR_Undo.Record(Bus, "Changed Bus"); Bus.Volume = newVolume; Bus.Pitch = newPitch; EditorUtility.SetDirty(Bus); } }