public static void AssetPopup <T>(SerializedProperty serializedProperty, GUIContent label, string fileExtension, string defaultFieldName) where T : UnityEngine.Object, new() { bool showMixedValue = EditorGUI.showMixedValue; EditorGUI.showMixedValue = serializedProperty.hasMultipleDifferentValues; string objectReferenceTypeString = serializedProperty.objectReferenceTypeString; GUIContent buttonContent; if (serializedProperty.hasMultipleDifferentValues) { buttonContent = EditorGUI.mixedValueContent; } else if (serializedProperty.objectReferenceValue != null) { buttonContent = GUIContent.Temp(serializedProperty.objectReferenceStringValue); } else { buttonContent = GUIContent.Temp(defaultFieldName); } Rect buttonRect; if (AudioMixerEffectGUI.PopupButton(label, buttonContent, EditorStyles.popup, out buttonRect, new GUILayoutOption[0])) { AssetPopupBackend.ShowAssetsPopupMenu <T>(buttonRect, objectReferenceTypeString, serializedProperty, fileExtension, defaultFieldName); } EditorGUI.showMixedValue = showMixedValue; }
public static void AssetPopup <T>(SerializedProperty serializedProperty, GUIContent label, string fileExtension, string defaultFieldName) where T : Object, new() { bool orignalShowMixedValue = EditorGUI.showMixedValue; EditorGUI.showMixedValue = serializedProperty.hasMultipleDifferentValues; var typeName = serializedProperty.objectReferenceTypeString; GUIContent buttonContent; if (serializedProperty.hasMultipleDifferentValues) { buttonContent = EditorGUI.mixedValueContent; } else if (serializedProperty.objectReferenceValue != null) { buttonContent = GUIContent.Temp(serializedProperty.objectReferenceStringValue); } else { buttonContent = GUIContent.Temp(defaultFieldName); } Rect buttonRect; if (AudioMixerEffectGUI.PopupButton(label, buttonContent, EditorStyles.popup, out buttonRect)) // move & rename PopupButton.. { ShowAssetsPopupMenu <T>(buttonRect, typeName, serializedProperty, fileExtension, defaultFieldName); } EditorGUI.showMixedValue = orignalShowMixedValue; }
public static void AssetPopup <T>(SerializedProperty serializedProperty, GUIContent label, string fileExtension) where T : UnityEngine.Object, new() { GUIContent mixedValueContent; Rect rect; bool showMixedValue = EditorGUI.showMixedValue; EditorGUI.showMixedValue = serializedProperty.hasMultipleDifferentValues; string objectReferenceTypeString = serializedProperty.objectReferenceTypeString; if (serializedProperty.hasMultipleDifferentValues) { mixedValueContent = EditorGUI.mixedValueContent; } else if (serializedProperty.objectReferenceValue != null) { mixedValueContent = GUIContent.Temp(serializedProperty.objectReferenceStringValue); } else { mixedValueContent = GUIContent.Temp("Default"); } if (AudioMixerEffectGUI.PopupButton(label, mixedValueContent, EditorStyles.popup, out rect, new GUILayoutOption[0])) { ShowAssetsPopupMenu <T>(rect, objectReferenceTypeString, serializedProperty, fileExtension); } EditorGUI.showMixedValue = showMixedValue; }
public static float DoInitialModule(AudioMixerGroupController group, AudioMixerController controller, List <AudioMixerGroupController> allGroups) { Rect rect = EditorGUILayout.BeginVertical(EditorStyles.inspectorDefaultMargins, new GUILayoutOption[0]); float valueForPitch = group.GetValueForPitch(controller, controller.TargetSnapshot); if (AudioMixerEffectGUI.Slider(AudioMixerEffectView.Texts.pitch, ref valueForPitch, 100f, 1f, AudioMixerEffectView.Texts.percentage, 0.01f, 10f, controller, new AudioGroupParameterPath(group, group.GetGUIDForPitch()), new GUILayoutOption[0])) { group.SetValueForPitch(controller, controller.TargetSnapshot, valueForPitch); } GUILayout.Space(5f); EditorGUILayout.EndVertical(); AudioMixerDrawUtils.DrawSplitter(); return(rect.height); }
public static void AssetPopup <T>(SerializedProperty serializedProperty, GUIContent label, string fileExtension) where T : Object, new() { bool showMixedValue = EditorGUI.showMixedValue; EditorGUI.showMixedValue = serializedProperty.hasMultipleDifferentValues; string referenceTypeString = serializedProperty.objectReferenceTypeString; GUIContent buttonContent = !serializedProperty.hasMultipleDifferentValues ? (!(serializedProperty.objectReferenceValue != (Object)null) ? GUIContent.Temp("Default") : GUIContent.Temp(serializedProperty.objectReferenceStringValue)) : EditorGUI.mixedValueContent; Rect buttonRect; if (AudioMixerEffectGUI.PopupButton(label, buttonContent, EditorStyles.popup, out buttonRect)) { AssetPopupBackend.ShowAssetsPopupMenu <T>(buttonRect, referenceTypeString, serializedProperty, fileExtension); } EditorGUI.showMixedValue = showMixedValue; }
public static float DoInitialModule(AudioMixerGroupController group, AudioMixerController controller, List <AudioMixerGroupController> allGroups) { Rect totalRect = EditorGUILayout.BeginVertical(EditorStyles.inspectorDefaultMargins); // Pitch float value = group.GetValueForPitch(controller, controller.TargetSnapshot); if (AudioMixerEffectGUI.Slider(Texts.pitch, ref value, 100.0f, 1.0f, Texts.percentage, kMinPitch, kMaxPitch, controller, new AudioGroupParameterPath(group, group.GetGUIDForPitch()))) { Undo.RecordObject(controller.TargetSnapshot, "Change Pitch"); group.SetValueForPitch(controller, controller.TargetSnapshot, value); } GUILayout.Space(5f); EditorGUILayout.EndVertical(); AudioMixerDrawUtils.DrawSplitter(); return(totalRect.height); }
public void DoEffectGUI(int effectIndex, AudioMixerGroupController group, List <AudioMixerGroupController> allGroups, Dictionary <AudioMixerEffectController, AudioMixerGroupController> effectMap, ref int highlightEffectIndex) { Event current = Event.current; AudioMixerController controller = group.controller; AudioMixerEffectController audioMixerEffectController = group.effects[effectIndex]; MixerParameterDefinition[] effectParameters = MixerEffectDefinitions.GetEffectParameters(audioMixerEffectController.effectName); Rect effectRect = EditorGUILayout.BeginVertical(new GUILayoutOption[0]); bool flag = effectRect.Contains(current.mousePosition); EventType typeForControl = current.GetTypeForControl(this.m_EffectDragging.dragControlID); if (typeForControl == EventType.MouseMove && flag && highlightEffectIndex != effectIndex) { highlightEffectIndex = effectIndex; AudioMixerUtility.RepaintAudioMixerAndInspectors(); } Rect rect = GUILayoutUtility.GetRect(1f, 17f); Rect rect2 = new Rect(rect.x + 6f, rect.y + 5f, 6f, 6f); Rect position = new Rect(rect.x + 8f + 6f, rect.y, rect.width - 8f - 6f - 14f - 5f, rect.height); Rect rect3 = new Rect(position.xMax, rect.y, 14f, 14f); Rect rect4 = new Rect(rect.x, rect.y, rect.width - 14f - 5f, rect.height); bool flag2 = EditorPrefs.GetBool(AudioMixerGroupEditor.kPrefKeyForShowCpuUsage, false) && EditorUtility.audioProfilingEnabled; float num = (!EditorGUIUtility.isProSkin) ? 1f : 0.1f; Color color = new Color(num, num, num, 0.2f); Color color2 = GUI.color; GUI.color = color; GUI.DrawTexture(rect, EditorGUIUtility.whiteTexture); GUI.color = color2; Color effectColor = AudioMixerDrawUtils.GetEffectColor(audioMixerEffectController); EditorGUI.DrawRect(rect2, effectColor); GUI.Label(position, (!flag2) ? audioMixerEffectController.effectName : (audioMixerEffectController.effectName + string.Format(AudioMixerEffectView.Texts.cpuFormatString, audioMixerEffectController.GetCPUUsage(controller))), EditorStyles.boldLabel); if (EditorGUI.ButtonMouseDown(rect3, EditorGUI.GUIContents.titleSettingsIcon, FocusType.Passive, EditorStyles.inspectorTitlebarText)) { AudioMixerEffectView.ShowEffectContextMenu(group, audioMixerEffectController, effectIndex, controller, rect3); } if (current.type == EventType.ContextClick && rect.Contains(current.mousePosition)) { AudioMixerEffectView.ShowEffectContextMenu(group, audioMixerEffectController, effectIndex, controller, new Rect(current.mousePosition.x, rect.y, 1f, rect.height)); current.Use(); } if (typeForControl == EventType.Repaint) { EditorGUIUtility.AddCursorRect(rect4, MouseCursor.ResizeVertical, this.m_EffectDragging.dragControlID); } using (new EditorGUI.DisabledScope(audioMixerEffectController.bypass || group.bypassEffects)) { EditorGUILayout.BeginVertical(EditorStyles.inspectorDefaultMargins, new GUILayoutOption[0]); if (audioMixerEffectController.IsAttenuation()) { EditorGUILayout.BeginVertical(new GUILayoutOption[0]); float valueForVolume = group.GetValueForVolume(controller, controller.TargetSnapshot); if (AudioMixerEffectGUI.Slider(AudioMixerEffectView.Texts.volume, ref valueForVolume, 1f, 1f, AudioMixerEffectView.Texts.dB, AudioMixerController.kMinVolume, AudioMixerController.GetMaxVolume(), controller, new AudioGroupParameterPath(group, group.GetGUIDForVolume()), new GUILayoutOption[0])) { Undo.RecordObject(controller.TargetSnapshot, "Change Volume Fader"); group.SetValueForVolume(controller, controller.TargetSnapshot, valueForVolume); AudioMixerUtility.RepaintAudioMixerAndInspectors(); } float[] array = new float[9]; float[] array2 = new float[9]; int num2 = group.controller.GetGroupVUInfo(group.groupID, true, ref array, ref array2); if (current.type == EventType.Layout) { this.m_LastNumChannels = num2; } else { if (num2 != this.m_LastNumChannels) { HandleUtility.Repaint(); } num2 = this.m_LastNumChannels; } GUILayout.Space(4f); for (int i = 0; i < num2; i++) { float value = 1f - AudioMixerController.VolumeToScreenMapping(Mathf.Clamp(array[i], AudioMixerController.kMinVolume, AudioMixerController.GetMaxVolume()), 1f, true); float num3 = 1f - AudioMixerController.VolumeToScreenMapping(Mathf.Clamp(array2[i], AudioMixerController.kMinVolume, AudioMixerController.GetMaxVolume()), 1f, true); EditorGUILayout.VUMeterHorizontal(value, num3, new GUILayoutOption[] { GUILayout.Height(10f) }); if (!EditorApplication.isPlaying && num3 > 0f) { AudioMixerUtility.RepaintAudioMixerAndInspectors(); } } GUILayout.Space(4f); EditorGUILayout.EndVertical(); } if (audioMixerEffectController.IsSend()) { GUIContent buttonContent = (!(audioMixerEffectController.sendTarget == null)) ? GUIContent.Temp(audioMixerEffectController.GetSendTargetDisplayString(effectMap)) : AudioMixerEffectView.Texts.none; Rect buttonRect; if (AudioMixerEffectGUI.PopupButton(AudioMixerEffectView.Texts.bus, buttonContent, EditorStyles.popup, out buttonRect, new GUILayoutOption[0])) { AudioMixerEffectView.ShowBusPopupMenu(effectIndex, group, allGroups, effectMap, audioMixerEffectController, buttonRect); } if (audioMixerEffectController.sendTarget != null) { float valueForMixLevel = audioMixerEffectController.GetValueForMixLevel(controller, controller.TargetSnapshot); if (AudioMixerEffectGUI.Slider(AudioMixerEffectView.Texts.sendLevel, ref valueForMixLevel, 1f, 1f, AudioMixerEffectView.Texts.dB, AudioMixerController.kMinVolume, AudioMixerController.kMaxEffect, controller, new AudioEffectParameterPath(group, audioMixerEffectController, audioMixerEffectController.GetGUIDForMixLevel()), new GUILayoutOption[0])) { Undo.RecordObject(controller.TargetSnapshot, "Change Send Level"); audioMixerEffectController.SetValueForMixLevel(controller, controller.TargetSnapshot, valueForMixLevel); AudioMixerUtility.RepaintAudioMixerAndInspectors(); } } } if (MixerEffectDefinitions.EffectCanBeSidechainTarget(audioMixerEffectController)) { bool flag3 = false; foreach (AudioMixerGroupController current2 in allGroups) { AudioMixerEffectController[] effects = current2.effects; for (int j = 0; j < effects.Length; j++) { AudioMixerEffectController audioMixerEffectController2 = effects[j]; if (audioMixerEffectController2.IsSend() && audioMixerEffectController2.sendTarget == audioMixerEffectController) { flag3 = true; break; } if (flag3) { break; } } if (flag3) { break; } } if (!flag3) { GUILayout.Label(new GUIContent("No Send sources connected.", EditorGUIUtility.warningIcon), new GUILayoutOption[0]); } } if (audioMixerEffectController.enableWetMix && !audioMixerEffectController.IsReceive() && !audioMixerEffectController.IsDuckVolume() && !audioMixerEffectController.IsAttenuation() && !audioMixerEffectController.IsSend()) { float valueForMixLevel2 = audioMixerEffectController.GetValueForMixLevel(controller, controller.TargetSnapshot); if (AudioMixerEffectGUI.Slider(AudioMixerEffectView.Texts.wet, ref valueForMixLevel2, 1f, 1f, AudioMixerEffectView.Texts.dB, AudioMixerController.kMinVolume, AudioMixerController.kMaxEffect, controller, new AudioEffectParameterPath(group, audioMixerEffectController, audioMixerEffectController.GetGUIDForMixLevel()), new GUILayoutOption[0])) { Undo.RecordObject(controller.TargetSnapshot, "Change Mix Level"); audioMixerEffectController.SetValueForMixLevel(controller, controller.TargetSnapshot, valueForMixLevel2); AudioMixerUtility.RepaintAudioMixerAndInspectors(); } } bool flag4 = true; if (this.m_CustomEffectGUIs.ContainsKey(audioMixerEffectController.effectName)) { IAudioEffectPluginGUI audioEffectPluginGUI = this.m_CustomEffectGUIs[audioMixerEffectController.effectName]; this.m_SharedPlugin.m_Controller = controller; this.m_SharedPlugin.m_Effect = audioMixerEffectController; this.m_SharedPlugin.m_ParamDefs = effectParameters; flag4 = audioEffectPluginGUI.OnGUI(this.m_SharedPlugin); } if (flag4) { MixerParameterDefinition[] array3 = effectParameters; for (int k = 0; k < array3.Length; k++) { MixerParameterDefinition mixerParameterDefinition = array3[k]; float valueForParameter = audioMixerEffectController.GetValueForParameter(controller, controller.TargetSnapshot, mixerParameterDefinition.name); if (AudioMixerEffectGUI.Slider(GUIContent.Temp(mixerParameterDefinition.name, mixerParameterDefinition.description), ref valueForParameter, mixerParameterDefinition.displayScale, mixerParameterDefinition.displayExponent, mixerParameterDefinition.units, mixerParameterDefinition.minRange, mixerParameterDefinition.maxRange, controller, new AudioEffectParameterPath(group, audioMixerEffectController, audioMixerEffectController.GetGUIDForParameter(mixerParameterDefinition.name)), new GUILayoutOption[0])) { Undo.RecordObject(controller.TargetSnapshot, "Change " + mixerParameterDefinition.name); audioMixerEffectController.SetValueForParameter(controller, controller.TargetSnapshot, mixerParameterDefinition.name, valueForParameter); } } if (effectParameters.Length > 0) { GUILayout.Space(6f); } } } this.m_EffectDragging.HandleDragElement(effectIndex, effectRect, rect4, group, allGroups); EditorGUILayout.EndVertical(); EditorGUILayout.EndVertical(); AudioMixerDrawUtils.DrawSplitter(); }
public void DoEffectGUI(int effectIndex, AudioMixerGroupController group, List <AudioMixerGroupController> allGroups, Dictionary <AudioMixerEffectController, AudioMixerGroupController> effectMap, ref int highlightEffectIndex) { Event current = Event.current; AudioMixerController controller = group.controller; AudioMixerEffectController effect1 = group.effects[effectIndex]; MixerParameterDefinition[] effectParameters = MixerEffectDefinitions.GetEffectParameters(effect1.effectName); Rect effectRect = EditorGUILayout.BeginVertical(); bool flag1 = effectRect.Contains(current.mousePosition); EventType typeForControl = current.GetTypeForControl(this.m_EffectDragging.dragControlID); if (typeForControl == EventType.MouseMove && flag1 && highlightEffectIndex != effectIndex) { highlightEffectIndex = effectIndex; AudioMixerUtility.RepaintAudioMixerAndInspectors(); } Rect rect1 = GUILayoutUtility.GetRect(1f, 17f); Rect rect2 = new Rect(rect1.x + 6f, rect1.y + 5f, 6f, 6f); Rect position = new Rect((float)((double)rect1.x + 8.0 + 6.0), rect1.y, (float)((double)rect1.width - 8.0 - 6.0 - 14.0 - 5.0), rect1.height); Rect rect3 = new Rect(position.xMax, rect1.y, 14f, 14f); Rect rect4 = new Rect(rect1.x, rect1.y, (float)((double)rect1.width - 14.0 - 5.0), rect1.height); bool flag2 = EditorPrefs.GetBool(AudioMixerGroupEditor.kPrefKeyForShowCpuUsage, false) && EditorUtility.audioProfilingEnabled; float num1 = !EditorGUIUtility.isProSkin ? 1f : 0.1f; Color color1 = new Color(num1, num1, num1, 0.2f); Color color2 = GUI.color; GUI.color = color1; GUI.DrawTexture(rect1, (Texture)EditorGUIUtility.whiteTexture); GUI.color = color2; Color effectColor = AudioMixerDrawUtils.GetEffectColor(effect1); EditorGUI.DrawRect(rect2, effectColor); GUI.Label(position, !flag2 ? effect1.effectName : effect1.effectName + string.Format(AudioMixerEffectView.Texts.cpuFormatString, (object)effect1.GetCPUUsage(controller)), EditorStyles.boldLabel); if (EditorGUI.ButtonMouseDown(rect3, EditorGUI.GUIContents.titleSettingsIcon, FocusType.Passive, EditorStyles.inspectorTitlebarText)) { AudioMixerEffectView.ShowEffectContextMenu(group, effect1, effectIndex, controller, rect3); } if (current.type == EventType.ContextClick && rect1.Contains(current.mousePosition)) { AudioMixerEffectView.ShowEffectContextMenu(group, effect1, effectIndex, controller, new Rect(current.mousePosition.x, rect1.y, 1f, rect1.height)); current.Use(); } if (typeForControl == EventType.Repaint) { EditorGUIUtility.AddCursorRect(rect4, MouseCursor.ResizeVertical, this.m_EffectDragging.dragControlID); } EditorGUI.BeginDisabledGroup(effect1.bypass || group.bypassEffects); EditorGUILayout.BeginVertical(EditorStyles.inspectorDefaultMargins, new GUILayoutOption[0]); if (effect1.IsAttenuation()) { EditorGUILayout.BeginVertical(); float valueForVolume = group.GetValueForVolume(controller, controller.TargetSnapshot); if (AudioMixerEffectGUI.Slider(AudioMixerEffectView.Texts.volume, ref valueForVolume, 1f, 1f, AudioMixerEffectView.Texts.dB, AudioMixerController.kMinVolume, AudioMixerController.GetMaxVolume(), controller, (AudioParameterPath) new AudioGroupParameterPath(group, group.GetGUIDForVolume()))) { Undo.RecordObject((UnityEngine.Object)controller.TargetSnapshot, "Change Volume Fader"); group.SetValueForVolume(controller, controller.TargetSnapshot, valueForVolume); AudioMixerUtility.RepaintAudioMixerAndInspectors(); } float[] vuLevel = new float[9]; float[] vuPeak = new float[9]; int num2 = group.controller.GetGroupVUInfo(group.groupID, true, ref vuLevel, ref vuPeak); if (current.type == EventType.Layout) { this.m_LastNumChannels = num2; } else { if (num2 != this.m_LastNumChannels) { HandleUtility.Repaint(); } num2 = this.m_LastNumChannels; } GUILayout.Space(4f); for (int index = 0; index < num2; ++index) { float num3 = 1f - AudioMixerController.VolumeToScreenMapping(Mathf.Clamp(vuLevel[index], AudioMixerController.kMinVolume, AudioMixerController.GetMaxVolume()), 1f, true); float peak = 1f - AudioMixerController.VolumeToScreenMapping(Mathf.Clamp(vuPeak[index], AudioMixerController.kMinVolume, AudioMixerController.GetMaxVolume()), 1f, true); EditorGUILayout.VUMeterHorizontal(num3, peak, new GUILayoutOption[1] { GUILayout.Height(10f) }); if (!EditorApplication.isPlaying && (double)peak > 0.0) { AudioMixerUtility.RepaintAudioMixerAndInspectors(); } } GUILayout.Space(4f); EditorGUILayout.EndVertical(); } if (effect1.IsSend()) { GUIContent buttonContent = !((UnityEngine.Object)effect1.sendTarget == (UnityEngine.Object)null) ? GUIContent.Temp(effect1.GetSendTargetDisplayString(effectMap)) : AudioMixerEffectView.Texts.none; Rect buttonRect; if (AudioMixerEffectGUI.PopupButton(AudioMixerEffectView.Texts.bus, buttonContent, EditorStyles.popup, out buttonRect)) { AudioMixerEffectView.ShowBusPopupMenu(effectIndex, group, allGroups, effectMap, effect1, buttonRect); } if ((UnityEngine.Object)effect1.sendTarget != (UnityEngine.Object)null) { float valueForMixLevel = effect1.GetValueForMixLevel(controller, controller.TargetSnapshot); if (AudioMixerEffectGUI.Slider(AudioMixerEffectView.Texts.sendLevel, ref valueForMixLevel, 1f, 1f, AudioMixerEffectView.Texts.dB, AudioMixerController.kMinVolume, AudioMixerController.kMaxEffect, controller, (AudioParameterPath) new AudioEffectParameterPath(group, effect1, effect1.GetGUIDForMixLevel()))) { Undo.RecordObject((UnityEngine.Object)controller.TargetSnapshot, "Change Send Level"); effect1.SetValueForMixLevel(controller, controller.TargetSnapshot, valueForMixLevel); AudioMixerUtility.RepaintAudioMixerAndInspectors(); } } } if (MixerEffectDefinitions.EffectCanBeSidechainTarget(effect1)) { bool flag3 = false; using (List <AudioMixerGroupController> .Enumerator enumerator = allGroups.GetEnumerator()) { while (enumerator.MoveNext()) { foreach (AudioMixerEffectController effect2 in enumerator.Current.effects) { if (effect2.IsSend() && (UnityEngine.Object)effect2.sendTarget == (UnityEngine.Object)effect1) { flag3 = true; break; } if (flag3) { break; } } if (flag3) { break; } } } if (!flag3) { GUILayout.Label(new GUIContent("No Send sources connected.", (Texture)EditorGUIUtility.warningIcon)); } } if (effect1.enableWetMix && !effect1.IsReceive() && (!effect1.IsDuckVolume() && !effect1.IsAttenuation()) && !effect1.IsSend()) { float valueForMixLevel = effect1.GetValueForMixLevel(controller, controller.TargetSnapshot); if (AudioMixerEffectGUI.Slider(AudioMixerEffectView.Texts.wet, ref valueForMixLevel, 1f, 1f, AudioMixerEffectView.Texts.dB, AudioMixerController.kMinVolume, AudioMixerController.kMaxEffect, controller, (AudioParameterPath) new AudioEffectParameterPath(group, effect1, effect1.GetGUIDForMixLevel()))) { Undo.RecordObject((UnityEngine.Object)controller.TargetSnapshot, "Change Mix Level"); effect1.SetValueForMixLevel(controller, controller.TargetSnapshot, valueForMixLevel); AudioMixerUtility.RepaintAudioMixerAndInspectors(); } } bool flag4 = true; if (this.m_CustomEffectGUIs.ContainsKey(effect1.effectName)) { IAudioEffectPluginGUI customEffectGuI = this.m_CustomEffectGUIs[effect1.effectName]; this.m_SharedPlugin.m_Controller = controller; this.m_SharedPlugin.m_Effect = effect1; this.m_SharedPlugin.m_ParamDefs = effectParameters; flag4 = customEffectGuI.OnGUI((IAudioEffectPlugin)this.m_SharedPlugin); } if (flag4) { foreach (MixerParameterDefinition parameterDefinition in effectParameters) { float valueForParameter = effect1.GetValueForParameter(controller, controller.TargetSnapshot, parameterDefinition.name); if (AudioMixerEffectGUI.Slider(GUIContent.Temp(parameterDefinition.name, parameterDefinition.description), ref valueForParameter, parameterDefinition.displayScale, parameterDefinition.displayExponent, parameterDefinition.units, parameterDefinition.minRange, parameterDefinition.maxRange, controller, (AudioParameterPath) new AudioEffectParameterPath(group, effect1, effect1.GetGUIDForParameter(parameterDefinition.name)))) { Undo.RecordObject((UnityEngine.Object)controller.TargetSnapshot, "Change " + parameterDefinition.name); effect1.SetValueForParameter(controller, controller.TargetSnapshot, parameterDefinition.name, valueForParameter); } } if (effectParameters.Length > 0) { GUILayout.Space(6f); } } EditorGUI.EndDisabledGroup(); this.m_EffectDragging.HandleDragElement(effectIndex, effectRect, rect4, group, allGroups); EditorGUILayout.EndVertical(); EditorGUILayout.EndVertical(); AudioMixerDrawUtils.DrawSplitter(); }
public void DoEffectGUI(int effectIndex, AudioMixerGroupController group, List <AudioMixerGroupController> allGroups, Dictionary <AudioMixerEffectController, AudioMixerGroupController> effectMap, ref int highlightEffectIndex) { Event evt = Event.current; AudioMixerController controller = group.controller; AudioMixerEffectController effect = group.effects[effectIndex]; MixerParameterDefinition[] paramDefs = MixerEffectDefinitions.GetEffectParameters(effect.effectName); // This rect is valid after every layout event Rect totalRect = EditorGUILayout.BeginVertical(); bool hovering = totalRect.Contains(evt.mousePosition); EventType evtType = evt.GetTypeForControl(m_EffectDragging.dragControlID); if (evtType == EventType.MouseMove && hovering && highlightEffectIndex != effectIndex) { highlightEffectIndex = effectIndex; AudioMixerUtility.RepaintAudioMixerAndInspectors(); } // Header const float colorCodeWidth = 6f; var gearSize = EditorStyles.iconButton.CalcSize(EditorGUI.GUIContents.titleSettingsIcon); Rect headerRect = GUILayoutUtility.GetRect(1, 17f); Rect colorCodeRect = new Rect(headerRect.x + 6f, headerRect.y + 5f, colorCodeWidth, colorCodeWidth); Rect labelRect = new Rect(headerRect.x + 8f + colorCodeWidth, headerRect.y, headerRect.width - 8f - colorCodeWidth - gearSize.x - 5f, headerRect.height); Rect gearRect = new Rect(labelRect.xMax, headerRect.y, gearSize.x, gearSize.y); Rect dragRect = new Rect(headerRect.x, headerRect.y, headerRect.width - gearSize.x - 5f, headerRect.height); { bool showCPU = EditorPrefs.GetBool(AudioMixerGroupEditor.kPrefKeyForShowCpuUsage, false) && EditorUtility.audioProfilingEnabled; float val = EditorGUIUtility.isProSkin ? 0.1f : 1.0f; Color headerColor = new Color(val, val, val, 0.2f); Color origColor = GUI.color; GUI.color = headerColor; GUI.DrawTexture(headerRect, EditorGUIUtility.whiteTexture); GUI.color = origColor; Color effectColorCode = AudioMixerDrawUtils.GetEffectColor(effect); EditorGUI.DrawRect(colorCodeRect, effectColorCode); GUI.Label(labelRect, showCPU ? effect.effectName + string.Format(Texts.cpuFormatString, effect.GetCPUUsage(controller)) : effect.effectName, EditorStyles.boldLabel); if (EditorGUI.DropdownButton(gearRect, EditorGUI.GUIContents.titleSettingsIcon, FocusType.Passive, EditorStyles.iconButton)) { ShowEffectContextMenu(group, effect, effectIndex, controller, gearRect); } // Show context menu if right clicking in header rect (for convenience) if (evt.type == EventType.ContextClick && headerRect.Contains(evt.mousePosition)) { ShowEffectContextMenu(group, effect, effectIndex, controller, new Rect(evt.mousePosition.x, headerRect.y, 1, headerRect.height)); evt.Use(); } if (evtType == EventType.Repaint) { EditorGUIUtility.AddCursorRect(dragRect, MouseCursor.ResizeVertical, m_EffectDragging.dragControlID); } } using (new EditorGUI.DisabledScope(effect.bypass || group.bypassEffects)) { EditorGUILayout.BeginVertical(EditorStyles.inspectorDefaultMargins); if (effect.IsAttenuation()) { EditorGUILayout.BeginVertical(); float value = group.GetValueForVolume(controller, controller.TargetSnapshot); if (AudioMixerEffectGUI.Slider(Texts.volume, ref value, 1.0f, 1.0f, Texts.dB, AudioMixerController.kMinVolume, AudioMixerController.GetMaxVolume(), controller, new AudioGroupParameterPath(group, group.GetGUIDForVolume()))) { Undo.RecordObject(controller.TargetSnapshot, "Change Volume Fader"); group.SetValueForVolume(controller, controller.TargetSnapshot, value); AudioMixerUtility.RepaintAudioMixerAndInspectors(); } //FIXME // 1) The VUMeter used is not in the same style that fits the rest of the Audio UI // 2) The layout of the VU meters is hacked together and a lot of magic numbers are used. int numChannels = 0; float[] vuinfo_level = new float[9]; float[] vuinfo_peak = new float[9]; numChannels = group.controller.GetGroupVUInfo(group.groupID, true, ref vuinfo_level, ref vuinfo_peak); if (evt.type == EventType.Layout) { m_LastNumChannels = numChannels; } else { if (numChannels != m_LastNumChannels) { HandleUtility.Repaint(); // Repaint to ensure correct rendered num channels } // Ensure same num channels as in layout event to not break IMGUI controlID handling numChannels = m_LastNumChannels; } GUILayout.Space(4f); for (int c = 0; c < numChannels; ++c) { float level = 1 - AudioMixerController.VolumeToScreenMapping(Mathf.Clamp(vuinfo_level[c], AudioMixerController.kMinVolume, AudioMixerController.GetMaxVolume()), 1, true); float peak = 1 - AudioMixerController.VolumeToScreenMapping(Mathf.Clamp(vuinfo_peak[c], AudioMixerController.kMinVolume, AudioMixerController.GetMaxVolume()), 1, true); EditorGUILayout.VUMeterHorizontal(level, peak, GUILayout.Height(10)); //This allows the meters to drop to 0 after PlayMode has stopped. if (!EditorApplication.isPlaying && peak > 0.0F) { AudioMixerUtility.RepaintAudioMixerAndInspectors(); } } GUILayout.Space(4f); EditorGUILayout.EndVertical(); } if (effect.IsSend()) { Rect buttonRect; GUIContent buttonContent = (effect.sendTarget == null) ? Texts.none : GUIContent.Temp(effect.GetSendTargetDisplayString(effectMap)); if (AudioMixerEffectGUI.PopupButton(Texts.bus, buttonContent, EditorStyles.popup, out buttonRect)) { ShowBusPopupMenu(effectIndex, @group, allGroups, effectMap, effect, buttonRect); } if (effect.sendTarget != null) { float wetLevel = effect.GetValueForMixLevel(controller, controller.TargetSnapshot); if (AudioMixerEffectGUI.Slider(Texts.sendLevel, ref wetLevel, 1.0f, 1.0f, Texts.dB, AudioMixerController.kMinVolume, AudioMixerController.kMaxEffect, controller, new AudioGroupParameterPath(group, group.GetGUIDForSend()))) { Undo.RecordObject(controller.TargetSnapshot, "Change Send Level"); effect.SetValueForMixLevel(controller, controller.TargetSnapshot, wetLevel); AudioMixerUtility.RepaintAudioMixerAndInspectors(); } } } if (MixerEffectDefinitions.EffectCanBeSidechainTarget(effect)) { bool anyTargetsFound = false; foreach (var g in allGroups) { foreach (var e in g.effects) { if (e.IsSend() && e.sendTarget == effect) { anyTargetsFound = true; break; } } if (anyTargetsFound) { break; } } if (!anyTargetsFound) { GUILayout.Label(EditorGUIUtility.TrTextContent("No Send sources connected.", EditorGUIUtility.warningIcon)); } } // Wet mix if (effect.enableWetMix && !effect.IsReceive() && !effect.IsDuckVolume() && !effect.IsAttenuation() && !effect.IsSend()) { float wetLevel = effect.GetValueForMixLevel(controller, controller.TargetSnapshot); if (AudioMixerEffectGUI.Slider(Texts.wet, ref wetLevel, 1.0f, 1.0f, Texts.dB, AudioMixerController.kMinVolume, AudioMixerController.kMaxEffect, controller, new AudioEffectParameterPath(group, effect, effect.GetGUIDForMixLevel()))) { Undo.RecordObject(controller.TargetSnapshot, "Change Mix Level"); effect.SetValueForMixLevel(controller, controller.TargetSnapshot, wetLevel); AudioMixerUtility.RepaintAudioMixerAndInspectors(); } } // All other effects bool drawDefaultGUI = true; if (m_CustomEffectGUIs.ContainsKey(effect.effectName)) { var customGUI = m_CustomEffectGUIs[effect.effectName]; m_SharedPlugin.m_Controller = controller; m_SharedPlugin.m_Effect = effect; m_SharedPlugin.m_ParamDefs = paramDefs; drawDefaultGUI = customGUI.OnGUI(m_SharedPlugin); } if (drawDefaultGUI) { foreach (var p in paramDefs) { float value = effect.GetValueForParameter(controller, controller.TargetSnapshot, p.name); if (AudioMixerEffectGUI.Slider(GUIContent.Temp(p.name, p.description), ref value, p.displayScale, p.displayExponent, p.units, p.minRange, p.maxRange, controller, new AudioEffectParameterPath(group, effect, effect.GetGUIDForParameter(p.name)))) { Undo.RecordObject(controller.TargetSnapshot, "Change " + p.name); effect.SetValueForParameter(controller, controller.TargetSnapshot, p.name, value); } } if (paramDefs.Length > 0) { GUILayout.Space(6f); } } } m_EffectDragging.HandleDragElement(effectIndex, totalRect, dragRect, group, allGroups); EditorGUILayout.EndVertical(); // indented effect contents EditorGUILayout.EndVertical(); // calc total size AudioMixerDrawUtils.DrawSplitter(); }