public override void OnInspectorGUI() { serializedObject.Update(); if (m_Target.isDirty) { RefreshEditors(); m_Target.isDirty = false; } EditorGUILayout.PropertyField(m_IsGlobal); if (!m_IsGlobal.boolValue) // Blend radius is not needed for global volumes { EditorGUILayout.PropertyField(m_BlendRadius); } EditorGUILayout.PropertyField(m_Priority); EditorGUILayout.Space(); using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField(EditorUtilities.GetContent("Overrides"), EditorStyles.boldLabel); if (GUILayout.Button("Add effect...", EditorStyles.miniButton)) { var menu = new GenericMenu(); var typeMap = PostProcessVolumeManager.instance.settingsTypes; foreach (var kvp in typeMap) { var type = kvp.Key; var title = EditorUtilities.GetContent(kvp.Value.menuItem); bool exists = m_Target.HasSettings(type); if (!exists) { menu.AddItem(title, false, () => AddEffectOverride(type)); } else { menu.AddDisabledItem(title); } } menu.ShowAsContext(); } } // Override list for (int i = 0; i < m_Editors.Count; i++) { var editor = m_Editors[i]; string title = editor.GetDisplayTitle(); int id = i; // Needed for closure capture below EditorUtilities.DrawSplitter(); bool displayContent = EditorUtilities.DrawHeader( title, editor.baseProperty, editor.activeProperty, () => ResetEffectOverride(editor.target.GetType(), id), () => RemoveEffectOverride(id) ); if (displayContent) { using (new EditorGUI.DisabledScope(!editor.activeProperty.boolValue)) editor.OnInternalInspectorGUI(); } } if (m_Editors.Count > 0) { EditorUtilities.DrawSplitter(); EditorGUILayout.Space(); } serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { serializedObject.Update(); EditorGUILayout.LabelField(EditorUtilities.GetContent("Volume blending"), EditorStyles.boldLabel); EditorGUI.indentLevel++; { // The layout system sort of break alignement when mixing inspector fields with // custom layouted fields, do the layout manually instead var indentOffset = EditorGUI.indentLevel * 15f; var lineRect = GUILayoutUtility.GetRect(1, EditorGUIUtility.singleLineHeight); var labelRect = new Rect(lineRect.x, lineRect.y, EditorGUIUtility.labelWidth - indentOffset, lineRect.height); var fieldRect = new Rect(labelRect.xMax, lineRect.y, lineRect.width - labelRect.width - 60f, lineRect.height); var buttonRect = new Rect(fieldRect.xMax, lineRect.y, 60f, lineRect.height); EditorGUI.PrefixLabel(labelRect, EditorUtilities.GetContent("Trigger|A transform that will act as a trigger for volume blending.")); m_VolumeTrigger.objectReferenceValue = (Transform)EditorGUI.ObjectField(fieldRect, m_VolumeTrigger.objectReferenceValue, typeof(Transform), false); if (GUI.Button(buttonRect, EditorUtilities.GetContent("This|Assigns the current GameObject as a trigger."), EditorStyles.miniButton)) { m_VolumeTrigger.objectReferenceValue = m_Target.transform; } if (m_VolumeTrigger.objectReferenceValue == null) { EditorGUILayout.HelpBox("No trigger has been set, the camera will only be affected by global volumes.", MessageType.Info); } EditorGUILayout.PropertyField(m_VolumeLayer, EditorUtilities.GetContent("Layer|This camera will only be affected by volumes in the selected scene-layers.")); int mask = m_VolumeLayer.intValue; if (mask == 0) { EditorGUILayout.HelpBox("No layer has been set, the trigger will never be affected by volumes.", MessageType.Warning); } else if (mask == -1 || ((mask & 1) != 0)) { EditorGUILayout.HelpBox("Do not use \"Everything\" or \"Default\" as a layer mask as it will slow down the volume blending process! Put post-processing volumes in their own dedicated layer for best performances.", MessageType.Warning); } } EditorGUI.indentLevel--; EditorGUILayout.Space(); EditorGUILayout.LabelField(EditorUtilities.GetContent("Anti-aliasing"), EditorStyles.boldLabel); EditorGUI.indentLevel++; { m_AntialiasingMode.intValue = EditorGUILayout.Popup(EditorUtilities.GetContent("Mode|The anti-aliasing method to use. FXAA is fast but low quality. SMAA works well for non-HDR scenes. TAA is a bit slower but higher quality and works well with HDR."), m_AntialiasingMode.intValue, s_AntialiasingMethodNames); if (m_AntialiasingMode.intValue == (int)PostProcessLayer.Antialiasing.TemporalAntialiasing) { if (RuntimeUtilities.isSinglePassStereoEnabled) { EditorGUILayout.HelpBox("TAA doesn't work with Single-pass stereo rendering.", MessageType.Warning); } EditorGUILayout.PropertyField(m_TaaJitterSpread); EditorGUILayout.PropertyField(m_TaaStationaryBlending); EditorGUILayout.PropertyField(m_TaaMotionBlending); EditorGUILayout.PropertyField(m_TaaSharpen); } else if (m_AntialiasingMode.intValue == (int)PostProcessLayer.Antialiasing.SubpixelMorphologicalAntialiasing) { if (RuntimeUtilities.isSinglePassStereoEnabled) { EditorGUILayout.HelpBox("SMAA doesn't work with Single-pass stereo rendering.", MessageType.Warning); } } else if (m_AntialiasingMode.intValue == (int)PostProcessLayer.Antialiasing.FastApproximateAntialiasing) { EditorGUILayout.PropertyField(m_FxaaMobileOptimized); } } EditorGUI.indentLevel--; EditorGUILayout.Space(); EditorGUILayout.LabelField(EditorUtilities.GetContent("Debug Layer"), EditorStyles.boldLabel); EditorGUI.indentLevel++; { EditorGUILayout.PropertyField(m_DebugDisplay, EditorUtilities.GetContent("Display|Toggle visibility of the debug layer on & off in the Game View.")); if (m_DebugDisplay.boolValue) { if (!SystemInfo.supportsComputeShaders) { EditorGUILayout.HelpBox("The debug layer only works on compute-shader enabled platforms.", MessageType.Info); } EditorGUILayout.PropertyField(m_DebugMonitor, EditorUtilities.GetContent("Monitor|The real-time monitor to display on the debug layer.")); EditorGUILayout.PropertyField(m_DebugLightMeter, EditorUtilities.GetContent("HDR Light Meter|Light metering utility used to setup auto exposure. Note that it will only display correct values when using a full-HDR workflow (HDR camera, HDR/Custom color grading).")); } } EditorGUI.indentLevel--; EditorGUILayout.Space(); // Toolkit EditorUtilities.DrawSplitter(); GlobalSettings.showLayerToolkit = EditorUtilities.DrawHeader("Toolkit", GlobalSettings.showLayerToolkit); if (GlobalSettings.showLayerToolkit) { EditorGUILayout.Space(); if (GUILayout.Button(EditorUtilities.GetContent("Export frame to EXR..."), EditorStyles.miniButton)) { var menu = new GenericMenu(); menu.AddItem(EditorUtilities.GetContent("Full Frame (as displayed)"), false, () => ExportFrameToExr(ExportMode.FullFrame)); menu.AddItem(EditorUtilities.GetContent("Disable post-processing"), false, () => ExportFrameToExr(ExportMode.DisablePost)); menu.AddItem(EditorUtilities.GetContent("Break before Color Grading (Linear)"), false, () => ExportFrameToExr(ExportMode.BreakBeforeColorGradingLinear)); menu.AddItem(EditorUtilities.GetContent("Break before Color Grading (Log)"), false, () => ExportFrameToExr(ExportMode.BreakBeforeColorGradingLog)); menu.ShowAsContext(); } if (GUILayout.Button(EditorUtilities.GetContent("Select all layer volumes|Selects all the volumes that will influence this layer."), EditorStyles.miniButton)) { var volumes = RuntimeUtilities.GetAllSceneObjects <PostProcessVolume>() .Where(x => (m_VolumeLayer.intValue & (1 << x.gameObject.layer)) != 0) .Select(x => x.gameObject) .Cast <UnityEngine.Object>() .ToArray(); if (volumes.Length > 0) { Selection.objects = volumes; } } if (GUILayout.Button(EditorUtilities.GetContent("Select all active volumes|Selects all volumes currently affecting the layer."), EditorStyles.miniButton)) { var volumes = new List <PostProcessVolume>(); PostProcessManager.instance.GetActiveVolumes(m_Target, volumes); if (volumes.Count > 0) { Selection.objects = volumes .Select(x => x.gameObject) .Cast <UnityEngine.Object>() .ToArray(); } } EditorGUILayout.Space(); } // Custom user effects sorter EditorUtilities.DrawSplitter(); GlobalSettings.showCustomSorter = EditorUtilities.DrawHeader("Custom Effect Sorting", GlobalSettings.showCustomSorter); if (GlobalSettings.showCustomSorter) { EditorGUILayout.Space(); bool anyList = false; if (m_CustomLists != null) { foreach (var kvp in m_CustomLists) { var list = kvp.Value; // Skip empty lists to avoid polluting the inspector if (list.count == 0) { continue; } list.DoLayoutList(); anyList = true; } } if (!anyList) { EditorGUILayout.HelpBox("No custom effect loaded.", MessageType.Info); EditorGUILayout.Space(); } } EditorUtilities.DrawSplitter(); EditorGUILayout.Space(); serializedObject.ApplyModifiedProperties(); }
public void OnGUI() { if (m_Asset.isDirty) { RefreshEditors(); m_Asset.isDirty = false; } EditorGUILayout.LabelField(EditorUtilities.GetContent("Overrides"), EditorStyles.boldLabel); // Override list for (int i = 0; i < m_Editors.Count; i++) { var editor = m_Editors[i]; string title = editor.GetDisplayTitle(); int id = i; // Needed for closure capture below EditorUtilities.DrawSplitter(); bool displayContent = EditorUtilities.DrawHeader( title, editor.baseProperty, editor.activeProperty, editor.target, () => ResetEffectOverride(editor.target.GetType(), id), () => RemoveEffectOverride(id) ); if (displayContent) { using (new EditorGUI.DisabledScope(!editor.activeProperty.boolValue)) editor.OnInternalInspectorGUI(); } } if (m_Editors.Count > 0) { EditorUtilities.DrawSplitter(); EditorGUILayout.Space(); } else { EditorGUILayout.HelpBox("No override set on this volume.", MessageType.Info); } if (GUILayout.Button("Add effect...", EditorStyles.miniButton)) { var menu = new GenericMenu(); var typeMap = PostProcessManager.instance.settingsTypes; foreach (var kvp in typeMap) { var type = kvp.Key; var title = EditorUtilities.GetContent(kvp.Value.menuItem); bool exists = m_Asset.HasSettings(type); if (!exists) { menu.AddItem(title, false, () => AddEffectOverride(type)); } else { menu.AddDisabledItem(title); } } menu.ShowAsContext(); } EditorGUILayout.Space(); }