private void DrawRendererFeatureList() { EditorGUILayout.LabelField(Styles.RenderFeatures, EditorStyles.boldLabel); EditorGUILayout.Space(); if (m_RenderPasses.arraySize == 0) { EditorGUILayout.HelpBox("No Renderer Features added", MessageType.Info); } else { //Draw List CoreEditorUtils.DrawSplitter(); for (int i = 0; i < m_RenderPasses.arraySize; i++) { var prop = m_RenderPasses.GetArrayElementAtIndex(i); DrawRendererFeature(i, ref prop); CoreEditorUtils.DrawSplitter(); } } EditorGUILayout.Space(); //Add renderer if (GUILayout.Button("Add Renderer Feature", EditorStyles.miniButton)) { AddPassMenu(); } }
public void Draw(TUIState s, TData p, Editor owner) { var r = m_IsExpanded(s, p, owner); CoreEditorUtils.DrawSplitter(boxed); r.target = CoreEditorUtils.DrawHeaderFoldout(m_Title, r.target, boxed); // We must start with a layout group here // Otherwise, nested FadeGroup won't work GUILayout.BeginVertical(); if (animate && EditorGUILayout.BeginFadeGroup(r.faded) || !animate && r.target) { if (indent) { ++EditorGUI.indentLevel; } for (var i = 0; i < m_Bodies.Length; i++) { m_Bodies[i].Draw(s, p, owner); } if (indent) { --EditorGUI.indentLevel; } } if (animate) { EditorGUILayout.EndFadeGroup(); } GUILayout.EndVertical(); }
private void DrawBuildFeaturesList() { EditorGUILayout.LabelField(Styles.features, EditorStyles.boldLabel); EditorGUILayout.Space(); if (buildFeatures.arraySize == 0) { EditorGUILayout.HelpBox("No Build Features added", MessageType.Info); } else { CoreEditorUtils.DrawSplitter(); for (int i = 0; i < buildFeatures.arraySize; i++) { SerializedProperty prop = buildFeatures.GetArrayElementAtIndex(i); DrawBuildFeature(i, ref prop); CoreEditorUtils.DrawSplitter(); } } EditorGUILayout.Space(); if (GUILayout.Button("Add Build Feature", EditorStyles.miniButton)) { AddFeatureMenu(); } }
private void DrawRendererFeatureList() { EditorGUILayout.LabelField(Styles.RenderFeatures, EditorStyles.boldLabel); EditorGUILayout.Space(); if (m_RendererFeatures.arraySize == 0) { EditorGUILayout.HelpBox("No Renderer Features added", MessageType.Info); } else { //Draw List CoreEditorUtils.DrawSplitter(); for (int i = 0; i < m_RendererFeatures.arraySize; i++) { SerializedProperty renderFeaturesProperty = m_RendererFeatures.GetArrayElementAtIndex(i); DrawRendererFeature(i, ref renderFeaturesProperty); CoreEditorUtils.DrawSplitter(); } } EditorGUILayout.Space(); //Add renderer using (var hscope = new EditorGUILayout.HorizontalScope()) { if (GUILayout.Button("Add Renderer Feature", EditorStyles.miniButton)) { var r = hscope.rect; var pos = new Vector2(r.x + r.width / 2f, r.yMax + 18f); FilterWindow.Show(pos, new ScriptableRendererFeatureProvider(this)); } } }
public override void OnInspectorGUI() { m_SerializedAdditionalLightData.Update(); m_SerializedAdditionalShadowData.Update(); // Disable the default light editor for the release, it is just use for development /* * // Temporary toggle to go back to the old editor & separated additional datas * bool useOldInspector = m_AdditionalLightData.useOldInspector.boolValue; * * if (GUILayout.Button("Toggle default light editor")) * useOldInspector = !useOldInspector; * * m_AdditionalLightData.useOldInspector.boolValue = useOldInspector; * * if (useOldInspector) * { * DrawDefaultInspector(); * ApplyAdditionalComponentsVisibility(false); * m_SerializedAdditionalShadowData.ApplyModifiedProperties(); * m_SerializedAdditionalLightData.ApplyModifiedProperties(); * return; * } */ // New editor ApplyAdditionalComponentsVisibility(true); CheckStyles(); settings.Update(); ResolveLightShape(); DrawFoldout(m_AdditionalLightData.showFeatures, "Features", DrawFeatures); DrawFoldout(settings.lightType, "Shape", DrawShape); DrawFoldout(settings.intensity, "Light", DrawLightSettings); if (settings.shadowsType.enumValueIndex != (int)LightShadows.None) { DrawFoldout(settings.shadowsType, "Shadows", DrawShadows); } CoreEditorUtils.DrawSplitter(); EditorGUILayout.Space(); UpdateAreaLightEmissiveMeshSize(); m_SerializedAdditionalShadowData.ApplyModifiedProperties(); m_SerializedAdditionalLightData.ApplyModifiedProperties(); settings.ApplyModifiedProperties(); if (m_UpdateAreaLightEmissiveMesh) { UpdateAreaLightEmissiveMesh(); } }
public void ShowGUI() { EditorGUILayout.Space(); for (var i = 0; i < _binders.arraySize; i++) { Action <int> showPropertyBinderEditor = ShowPropertyBinderEditor; showPropertyBinderEditor(i); } CoreEditorUtils.DrawSplitter(); EditorGUILayout.Space(); // "Add Property Binder" button var rect = EditorGUILayout.GetControlRect(); rect.x += (rect.width - 200) / 2; rect.width = 200; if (GUI.Button(rect, "Add " + _datatype + " Property Binder")) { switch (_datatype) { case "bool": OnAddNewPropertyBinder <BoolValuePropertyBinder>(); break; case "float": CreateFloatPropertyBinderMenu().DropDown(rect); break; case "Vector3": OnAddNewPropertyBinder <Vector3ValuePropertyBinder>(); break; case "Color": OnAddNewPropertyBinder <ColorValuePropertyBinder>(); break; case "string": OnAddNewPropertyBinder <StringValuePropertyBinder>(); break; case "int": OnAddNewPropertyBinder <IntValuePropertyBinder>(); break; default: Debug.LogError("dataType not supported: " + _datatype); break; } } }
public override void OnInspectorGUI() { m_SerializedAdditionalLightData.Update(); m_SerializedAdditionalShadowData.Update(); m_SerializedCachedShadowData.Update(); bool useOldInspector = m_AdditionalLightData.useOldInspector.boolValue; if (GUILayout.Button("Toggle default light editor")) { useOldInspector = !useOldInspector; } m_AdditionalLightData.useOldInspector.boolValue = useOldInspector; if (useOldInspector) { DrawDefaultInspector(); ApplyAdditionalComponentVisibility(false); m_SerializedAdditionalShadowData.ApplyModifiedProperties(); m_SerializedAdditionalLightData.ApplyModifiedProperties(); m_SerializedCachedShadowData.ApplyModifiedProperties(); return; } //New editor ApplyAdditionalComponentVisibility(true); CheckStyles(); serializedObject.Update(); ResolveLightShape(); DrawFoldout(m_AdditionalLightData.showFeatures, "Features", DrawFeatures); DrawFoldout(m_BaseData.type, "Shape", DrawShape); DrawFoldout(m_BaseData.intensity, "Light", DrawLightSettings); if (m_BaseData.shadowsType.enumValueIndex != (int)LightShadows.None) { DrawFoldout(m_BaseData.shadowsType, "Shadows", DrawShadows); } CoreEditorUtils.DrawSplitter(); EditorGUILayout.Space(); m_SerializedAdditionalShadowData.ApplyModifiedProperties(); m_SerializedAdditionalLightData.ApplyModifiedProperties(); m_SerializedCachedShadowData.ApplyModifiedProperties(); serializedObject.ApplyModifiedProperties(); }
// This one is private as we do not want to have unhandled advanced switch. Change it if necessary. static IDrawer FoldoutGroup <TEnum, TState>(GUIContent title, TEnum mask, ExpandedState <TEnum, TState> state, FoldoutOption options, Enabler isAdvanced, SwitchEnabler switchAdvanced, params ActionDrawer[] contentDrawers) where TEnum : struct, IConvertible { return(Group((data, owner) => { bool isBoxed = (options & FoldoutOption.Boxed) != 0; bool isIndented = (options & FoldoutOption.Indent) != 0; bool isSubFoldout = (options & FoldoutOption.SubFoldout) != 0; bool noSpaceAtEnd = (options & FoldoutOption.NoSpaceAtEnd) != 0; bool expended = state[mask]; bool newExpended = expended; if (isSubFoldout) { newExpended = CoreEditorUtils.DrawSubHeaderFoldout(title, expended, isBoxed, isAdvanced == null ? (Func <bool>)null : () => isAdvanced(data, owner), switchAdvanced == null ? (Action)null : () => switchAdvanced(data, owner)); } else { CoreEditorUtils.DrawSplitter(isBoxed); newExpended = CoreEditorUtils.DrawHeaderFoldout(title, expended, isBoxed, isAdvanced == null ? (Func <bool>)null : () => isAdvanced(data, owner), switchAdvanced == null ? (Action)null : () => switchAdvanced(data, owner)); } if (newExpended ^ expended) { state[mask] = newExpended; } if (newExpended) { if (isIndented) { ++EditorGUI.indentLevel; } for (var i = 0; i < contentDrawers.Length; i++) { contentDrawers[i](data, owner); } if (isIndented) { --EditorGUI.indentLevel; } if (!noSpaceAtEnd) { EditorGUILayout.Space(); } } })); }
void DrawPropertiesInspector(bool active, DrawSettingsMethod DrawProperties) { if (active) { EditorGUI.indentLevel++; EditorGUI.BeginChangeCheck(); DrawProperties(); if (EditorGUI.EndChangeCheck()) { ApplyChanges(); } EditorGUI.indentLevel--; } CoreEditorUtils.DrawSplitter(); }
static void DrawLayerNamesSettings(SerializedHDRenderPipelineGlobalSettings serialized, Editor owner) { var oldWidth = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = Styles.labelWidth; CoreEditorUtils.DrawSplitter(); DrawLightLayerNames(serialized, owner); CoreEditorUtils.DrawSplitter(); DrawDecalLayerNames(serialized, owner); CoreEditorUtils.DrawSplitter(); EditorGUILayout.Space(); EditorGUIUtility.labelWidth = oldWidth; }
static void Drawer_FrameSettings_Custom(int index, SerializedFrameSettings serialized, Editor owner) { var oldWidth = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = Styles.labelWidth; CoreEditorUtils.DrawSplitter(); m_ShowFrameSettings_Rendering[index] = CoreEditorUtils.DrawHeaderFoldout(Styles.renderingSettingsHeaderContent, m_ShowFrameSettings_Rendering[index]); if (m_ShowFrameSettings_Rendering[index]) { using (new EditorGUI.IndentLevelScope()) { FrameSettingsUI.Drawer_SectionRenderingSettings(serialized, owner, withOverride: false); } } CoreEditorUtils.DrawSplitter(); m_ShowFrameSettings_Lighting[index] = CoreEditorUtils.DrawHeaderFoldout(Styles.lightSettingsHeaderContent, m_ShowFrameSettings_Lighting[index]); if (m_ShowFrameSettings_Lighting[index]) { using (new EditorGUI.IndentLevelScope()) { FrameSettingsUI.Drawer_SectionLightingSettings(serialized, owner, withOverride: false); } } CoreEditorUtils.DrawSplitter(); m_ShowFrameSettings_AsyncCompute[index] = CoreEditorUtils.DrawHeaderFoldout(Styles.asyncComputeSettingsHeaderContent, m_ShowFrameSettings_AsyncCompute[index]); if (m_ShowFrameSettings_AsyncCompute[index]) { using (new EditorGUI.IndentLevelScope()) { FrameSettingsUI.Drawer_SectionAsyncComputeSettings(serialized, owner, withOverride: false); } } CoreEditorUtils.DrawSplitter(); m_ShowFrameSettings_LightLoopDebug[index] = CoreEditorUtils.DrawHeaderFoldout(Styles.lightLoopSettingsHeaderContent, m_ShowFrameSettings_LightLoopDebug[index]); if (m_ShowFrameSettings_LightLoopDebug[index]) { using (new EditorGUI.IndentLevelScope()) { FrameSettingsUI.Drawer_SectionLightLoopSettings(serialized, owner, withOverride: false); } } CoreEditorUtils.DrawSplitter(); EditorGUIUtility.labelWidth = oldWidth; }
void DrawFoldout(SerializedProperty foldoutProperty, string title, Action func) { CoreEditorUtils.DrawSplitter(); bool state = foldoutProperty.isExpanded; state = CoreEditorUtils.DrawHeaderFoldout(title, state); if (state) { EditorGUI.indentLevel++; func(); EditorGUI.indentLevel--; GUILayout.Space(2f); } foldoutProperty.isExpanded = state; }
/// <summary> /// Creates a material header scope to display the foldout in the material UI. /// </summary> /// <param name="title">Title of the header.</param> /// <param name="bitExpanded">Bit index which specifies the state of the header (whether it is open or collapsed) inside Editor Prefs.</param> /// <param name="materialEditor">The current material editor.</param> /// <param name="spaceAtEnd">Set this to true to make the block include space at the bottom of its UI. Set to false to not include any space.</param> /// <param name="colorDot">Specify a color to display a dot, like in the layered UI.</param> /// <param name="subHeader">Set to true to make this into a sub-header. This affects the style of the header. Set to false to make this use the standard style.</param> public MaterialHeaderScope(string title, uint bitExpanded, MaterialEditor materialEditor, bool spaceAtEnd = true, Color colorDot = default(Color), bool subHeader = false) { bool beforeExpended = materialEditor.GetExpandedAreas(bitExpanded); #if !UNITY_2020_1_OR_NEWER oldIndentLevel = EditorGUI.indentLevel; EditorGUI.indentLevel = subHeader ? 1 : 0; //fix for preset in 2019.3 (preset are one more indentation depth in material) #endif this.spaceAtEnd = spaceAtEnd; if (!subHeader) { CoreEditorUtils.DrawSplitter(); } GUILayout.BeginVertical(); bool saveChangeState = GUI.changed; if (colorDot != default(Color)) { title = " " + title; } expanded = subHeader ? CoreEditorUtils.DrawSubHeaderFoldout(title, beforeExpended) : CoreEditorUtils.DrawHeaderFoldout(title, beforeExpended); if (colorDot != default(Color)) { Rect dotRect = GUILayoutUtility.GetLastRect(); dotRect.width = 5; dotRect.height = 5; dotRect.y += 7; dotRect.x += 17; EditorGUI.DrawRect(dotRect, colorDot); } if (expanded ^ beforeExpended) { materialEditor.SetExpandedAreas((uint)bitExpanded, expanded); saveChangeState = true; } GUI.changed = saveChangeState; if (expanded) { ++EditorGUI.indentLevel; } }
public MaterialHeaderScope(string title, uint bitExpanded, MaterialEditor materialEditor, bool spaceAtEnd = true, Color colorDot = default(Color), bool subHeader = false) { bool beforeExpended = materialEditor.GetExpandedAreas(bitExpanded); this.spaceAtEnd = spaceAtEnd; if (!subHeader) { CoreEditorUtils.DrawSplitter(); } GUILayout.BeginVertical(); bool saveChangeState = GUI.changed; if (colorDot != default(Color)) { title = " " + title; } expanded = subHeader ? CoreEditorUtils.DrawSubHeaderFoldout(title, beforeExpended) : CoreEditorUtils.DrawHeaderFoldout(title, beforeExpended); if (colorDot != default(Color)) { Color previousColor = GUI.contentColor; GUI.contentColor = colorDot; Rect headerRect = GUILayoutUtility.GetLastRect(); headerRect.xMin += 16f; EditorGUI.LabelField(headerRect, "■"); GUI.contentColor = previousColor; } if (expanded ^ beforeExpended) { materialEditor.SetExpandedAreas((uint)bitExpanded, expanded); saveChangeState = true; } GUI.changed = saveChangeState; if (expanded) { ++EditorGUI.indentLevel; } }
void ShowPropertyBinderEditor(int index) { var prop = _binders.GetArrayElementAtIndex(index); var finder = new RelativePropertyFinder(prop); // Header CoreEditorUtils.DrawSplitter(); var toggle = CoreEditorUtils.DrawHeaderToggle (PropertyBinderNameUtil.Shorten(prop), prop, finder["Enabled"], pos => CreateHeaderContextMenu(index) .DropDown(new Rect(pos, Vector2.zero))); if (!toggle) { return; } _binders.serializedObject.Update(); EditorGUILayout.Space(); // Properties var target = finder["Target"]; EditorGUILayout.PropertyField(target); if (ComponentSelector.GetInstance(target).ShowGUI(target) && PropertySelector.GetInstance(target, finder["_propertyType"]) .ShowGUI(finder["PropertyName"])) { // EditorGUILayout.PropertyField(finder["Value0"], Styles.Value0); // EditorGUILayout.PropertyField(finder["Value1"], Styles.Value1); } _binders.serializedObject.ApplyModifiedProperties(); EditorGUILayout.Space(); }
public void ShowGUI() { EditorGUILayout.Space(); for (var i = 0; i < _binders.arraySize; i++) { ShowPropertyBinderEditor(i); } CoreEditorUtils.DrawSplitter(); EditorGUILayout.Space(); // "Add Property Binder" button var rect = EditorGUILayout.GetControlRect(); rect.x += (rect.width - 200) / 2; rect.width = 200; if (GUI.Button(rect, "Add Property Binder")) { CreateNewPropertyBinderMenu().DropDown(rect); } }
/// <summary> Create an IDrawer foldout header using an ExpandedState </summary> /// <param name="title">Title wanted for this foldout header</param> /// <param name="mask">Bit mask (enum) used to define the boolean saving the state in ExpandedState</param> /// <param name="state">The ExpandedState describing the component</param> /// <param name="contentDrawer">The content of the foldout header</param> public static IDrawer FoldoutGroup <TEnum, TState>(string title, TEnum mask, ExpandedState <TEnum, TState> state, params ActionDrawer[] contentDrawer) where TEnum : struct, IConvertible { return(Action((uiState, data, editor) => { CoreEditorUtils.DrawSplitter(); bool expended = state[mask]; bool newExpended = CoreEditorUtils.DrawHeaderFoldout(title, expended); if (newExpended ^ expended) { state[mask] = newExpended; } if (newExpended) { ++EditorGUI.indentLevel; for (var i = 0; i < contentDrawer.Length; i++) { contentDrawer[i](uiState, data, editor); } --EditorGUI.indentLevel; EditorGUILayout.Space(); } })); }
void DrawSections() { if (!stylizedWater.meshRenderer || !stylizedWater.meshRenderer.sharedMaterial || !stylizedWater.meshRenderer.enabled) { EditorGUILayout.Space(); EditorGUILayout.HelpBox("Object has no active mesh renderer and/or material. Please add those first.", MessageType.Warning); EditorGUILayout.Space(); return; } string name = stylizedWater.meshRenderer.sharedMaterial.shader.name; if (name != shaderName && name != mobileShaderName && name != underwaterShaderName) { EditorGUILayout.Space(); EditorGUILayout.HelpBox("Material incompatible. You should add a material that uses the Stylized Water shader.", MessageType.Warning); EditorGUILayout.Space(); return; } EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(EditorStyles.helpBox); EditorGUILayout.Space(); switch (name) { case shaderName: EditorGUILayout.LabelField(" " + stylizedWater.material.name); break; case mobileShaderName: EditorGUILayout.LabelField(" " + stylizedWater.material.name + " (Mobile Variant)"); break; case underwaterShaderName: EditorGUILayout.LabelField(" " + stylizedWater.material.name + " (Underwater Variant)"); break; } EditorGUILayout.Space(); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); CoreEditorUtils.DrawSplitter(); if (name == shaderName || name == mobileShaderName) { colorTransparencySettings = CoreEditorUtils.DrawHeaderFoldout("Colors and Transparency", colorTransparencySettings, false, (Func <bool>)null, null); DrawPropertiesInspector(colorTransparencySettings, DrawColorSettings); DrawPropertiesInspector(CoreEditorUtils.DrawHeaderToggle(EditorGUIUtility.TrTextContent("Surface Foam"), surfaceFoamExpanded, enableSurfaceFoam, null), DrawSurfaceFoamSettings); DrawPropertiesInspector(CoreEditorUtils.DrawHeaderToggle(EditorGUIUtility.TrTextContent("Intersection Effects"), intersectionEffectsExpanded, enableIntersectionEffects, null), DrawIntersectionEffectSettings); } if (name == shaderName) { DrawPropertiesInspector(CoreEditorUtils.DrawHeaderToggle(EditorGUIUtility.TrTextContent("Foam Shadows"), foamShadowsExpanded, enableFoamShadows, null), DrawFoamShadowSettings); causticsSettings = CoreEditorUtils.DrawHeaderFoldout("Caustics", causticsSettings, false, (Func <bool>)null, null); DrawPropertiesInspector(causticsSettings, DrawCausticsSettings); planarReflectionSettings = CoreEditorUtils.DrawHeaderFoldout("Planar Reflections", planarReflectionSettings, false, (Func <bool>)null, null); DrawPropertiesInspector(planarReflectionSettings, DrawPlanarReflectionSettings); surfaceSettings = CoreEditorUtils.DrawHeaderFoldout("Surface and Lighting", surfaceSettings, false, (Func <bool>)null, null); DrawPropertiesInspector(surfaceSettings, DrawSurfaceSettings); } if (name == mobileShaderName || name == underwaterShaderName) { DrawPropertiesInspector(CoreEditorUtils.DrawHeaderToggle(EditorGUIUtility.TrTextContent("Refraction"), refractionExpanded, enableRefraction, null), DrawRefractionSettings); } if (name == shaderName || name == mobileShaderName) { waveSettings = CoreEditorUtils.DrawHeaderFoldout("Waves", waveSettings, false, (Func <bool>)null, null); DrawPropertiesInspector(waveSettings, DrawWaveSettings); } if (name == shaderName || name == underwaterShaderName) { underwaterSettings = CoreEditorUtils.DrawHeaderFoldout("Underwater", underwaterSettings, false, (Func <bool>)null, null); DrawPropertiesInspector(underwaterSettings, DrawUnderwaterSettings); } additionalSettings = CoreEditorUtils.DrawHeaderFoldout("Additional Settings", additionalSettings, false, (Func <bool>)null, null); DrawPropertiesInspector(additionalSettings, DrawAdditionalSettings); EditorGUILayout.Space(); if (stylizedWater.meshRenderer.shadowCastingMode == UnityEngine.Rendering.ShadowCastingMode.On) { CoreEditorUtils.DrawFixMeBox("Water is casting shadows. \nYou should turn this off.", () => TurnOffWaterShadowCasting()); } }
public override void OnInspectorGUI() { if (!m_Target) { return; } using (new EditorGUILayout.HorizontalScope()) { if (GUILayout.Button("Populate")) { m_Target.Populate(); } if (GUILayout.Button("Apply")) { m_Target.Apply(); } if (GUILayout.Button("Reset")) { m_Target.Reset(); RefreshEditors(); Repaint(); } } serializedObject.Update(); if (m_Target.renderers.Length == 0) { EditorGUILayout.HelpBox($"{typeof(MaterialOverrideGroup)} contains no renderers.", MessageType.Info); return; } // Find null renderers var oldRenderers = new List <Renderer>(); foreach (var renderer in m_Target.renderers) { if (renderer == null) { continue; } oldRenderers.Add(renderer); } // Remove null renderers if (oldRenderers.Count != m_Renderers.arraySize) { m_Renderers.ClearArray(); foreach (var renderer in oldRenderers) { m_Renderers.arraySize += 1; m_Renderers.GetArrayElementAtIndex(m_Renderers.arraySize - 1).objectReferenceValue = (Object)renderer; } } EditorGUI.BeginChangeCheck(); CoreEditorUtils.DrawSplitter(); m_ShaderOverridesFoldout.value = EditorGUILayout.BeginFoldoutHeaderGroup(m_ShaderOverridesFoldout.value, "Shader Overrides"); if (m_ShaderOverridesFoldout.value) { var targetShaders = m_Target.shaders; for (int i = 0, count = targetShaders.Length; i < count; i++) { if (!m_Target.TryGetOverride(targetShaders[i], out var propertyOverrideList)) { continue; } if (!m_ShaderOverrideEditors.TryGetValue(propertyOverrideList, out var editor)) { continue; } // Draw material header CoreEditorUtils.DrawSplitter(); bool displayContent = CoreEditorUtils.DrawHeaderToggle( targetShaders[i].name, editor.baseProperty, editor.active, null, () => editor.showHidden, () => editor.showHidden = !editor.showHidden ); if (displayContent) { using (new EditorGUI.DisabledScope(!editor.active.boolValue)) { editor.OnInspectorGUI(); } } } if (m_Target.shaders.Length == 0) { EditorGUILayout.HelpBox($"{typeof(MaterialOverrideGroup)} contains no shaders.", MessageType.Info); } } EditorGUILayout.EndFoldoutHeaderGroup(); CoreEditorUtils.DrawSplitter(); m_MaterialOverridesFoldout.value = EditorGUILayout.BeginFoldoutHeaderGroup(m_MaterialOverridesFoldout.value, "Material Overrides"); if (m_MaterialOverridesFoldout.value) { var targetMaterials = m_Target.materials; // Draw materials for (int i = 0, count = targetMaterials.Length; i < count; i++) { if (!m_Target.TryGetOverride(targetMaterials[i], out var propertyOverrideList)) { continue; } if (!m_ShaderOverrideEditors.TryGetValue(propertyOverrideList, out var editor)) { continue; } // Draw material header CoreEditorUtils.DrawSplitter(); bool displayContent = CoreEditorUtils.DrawHeaderToggle( targetMaterials[i].name, editor.baseProperty, editor.active, null, () => editor.showHidden, () => editor.showHidden = !editor.showHidden ); if (displayContent) { using (new EditorGUI.DisabledScope(!editor.active.boolValue)) { editor.OnInspectorGUI(); } } } if (m_Target.materials.Length == 0) { EditorGUILayout.HelpBox($"{typeof(MaterialOverrideGroup)} contains no materials.", MessageType.Info); } } EditorGUILayout.EndFoldoutHeaderGroup(); serializedObject.ApplyModifiedProperties(); if (EditorGUI.EndChangeCheck()) { m_Target.Apply(); } }
//https://github.com/Unity-Technologies/Graphics/blob/d0473769091ff202422ad13b7b764c7b6a7ef0be/com.unity.render-pipelines.core/Editor/CoreEditorUtils.cs#L460 public static bool DrawHeader(string title, bool isExpanded, Action clickAction = null) { #if URP CoreEditorUtils.DrawSplitter(); #endif var backgroundRect = GUILayoutUtility.GetRect(1f, 25f); var labelRect = backgroundRect; labelRect.xMin += 8f; labelRect.xMax -= 20f + 16 + 5; var foldoutRect = backgroundRect; foldoutRect.xMin -= 8f; foldoutRect.y += 0f; foldoutRect.width = 25f; foldoutRect.height = 25f; // Background rect should be full-width backgroundRect.xMin = 0f; backgroundRect.width += 4f; // Background float backgroundTint = EditorGUIUtility.isProSkin ? 0.1f : 1f; EditorGUI.DrawRect(backgroundRect, new Color(backgroundTint, backgroundTint, backgroundTint, 0.2f)); // Title EditorGUI.LabelField(labelRect, title, EditorStyles.boldLabel); // Foldout isExpanded = GUI.Toggle(foldoutRect, isExpanded, new GUIContent(isExpanded ? "−" : "≡"), EditorStyles.boldLabel); // Context menu #if URP var menuIcon = CoreEditorStyles.paneOptionsIcon; #else Texture menuIcon = null; #endif var menuRect = new Rect(labelRect.xMax + 3f + 16 + 5, labelRect.y + 1f, menuIcon.width, menuIcon.height); //if (clickAction != null) //GUI.DrawTexture(menuRect, menuIcon); // Handle events var e = Event.current; if (e.type == EventType.MouseDown) { if (clickAction != null && menuRect.Contains(e.mousePosition)) { e.Use(); } else if (labelRect.Contains(e.mousePosition)) { if (e.button == 0) { isExpanded = !isExpanded; if (clickAction != null) { clickAction.Invoke(); } } e.Use(); } } #if URP //CoreEditorUtils.DrawSplitter(); #endif //GUILayout.Space(5f); return(isExpanded); }
public override void OnInspectorGUI() { CheckStyles(); // Display a warning if this settings asset is not currently in use if (m_HDPipeline == null || m_HDPipeline.sssSettings != m_Target) { EditorGUILayout.HelpBox("These profiles aren't currently in use, assign this asset to the HD render pipeline asset to use them.", MessageType.Warning); } serializedObject.Update(); EditorGUILayout.PropertyField(m_UseDisneySSS, s_Styles.useDisneySSS); EditorGUILayout.Space(); if (m_Profiles == null || m_Profiles.Count == 0) { return; } bool useDisneySSS = m_UseDisneySSS.boolValue; for (int i = 0; i < m_Profiles.Count; i++) { var profile = m_Profiles[i]; CoreEditorUtils.DrawSplitter(); bool state = profile.self.isExpanded; state = CoreEditorUtils.DrawHeaderFoldout(profile.name.stringValue, state); if (state) { EditorGUI.indentLevel++; EditorGUILayout.PropertyField(profile.name); using (var scope = new EditorGUI.ChangeCheckScope()) { if (useDisneySSS) { EditorGUILayout.PropertyField(profile.scatteringDistance, s_Styles.profileScatteringDistance); using (new EditorGUI.DisabledScope(true)) EditorGUILayout.FloatField(s_Styles.profileMaxRadius, profile.objReference.maxRadius); } else { EditorGUILayout.PropertyField(profile.scatterDistance1, s_Styles.profileScatterDistance1); EditorGUILayout.PropertyField(profile.scatterDistance2, s_Styles.profileScatterDistance2); EditorGUILayout.PropertyField(profile.lerpWeight, s_Styles.profileLerpWeight); } profile.texturingMode.intValue = EditorGUILayout.Popup(s_Styles.texturingMode, profile.texturingMode.intValue, s_Styles.texturingModeOptions); profile.transmissionMode.intValue = EditorGUILayout.Popup(s_Styles.profileTransmissionMode, profile.transmissionMode.intValue, s_Styles.transmissionModeOptions); EditorGUILayout.PropertyField(profile.transmissionTint, s_Styles.profileTransmissionTint); EditorGUILayout.PropertyField(profile.thicknessRemap, s_Styles.profileMinMaxThickness); var thicknessRemap = profile.thicknessRemap.vector2Value; EditorGUILayout.MinMaxSlider(s_Styles.profileThicknessRemap, ref thicknessRemap.x, ref thicknessRemap.y, 0f, 50f); profile.thicknessRemap.vector2Value = thicknessRemap; EditorGUILayout.PropertyField(profile.worldScale, s_Styles.profileWorldScale); EditorGUILayout.Slider(profile.fresnel0, 0.0f, 0.1f, s_Styles.profileFresnel0); EditorGUILayout.Space(); EditorGUILayout.LabelField(s_Styles.profilePreview0, s_Styles.centeredMiniBoldLabel); EditorGUILayout.LabelField(s_Styles.profilePreview1, EditorStyles.centeredGreyMiniLabel); EditorGUILayout.LabelField(s_Styles.profilePreview2, EditorStyles.centeredGreyMiniLabel); EditorGUILayout.LabelField(s_Styles.profilePreview3, EditorStyles.centeredGreyMiniLabel); EditorGUILayout.Space(); serializedObject.ApplyModifiedProperties(); if (scope.changed) { // Validate and update the cache for this profile only profile.objReference.Validate(); m_Target.UpdateCache(i); } } RenderPreview(profile, useDisneySSS); EditorGUILayout.Space(); EditorGUI.indentLevel--; } profile.self.isExpanded = state; } CoreEditorUtils.DrawSplitter(); serializedObject.ApplyModifiedProperties(); }
internal static bool DrawSectionFoldout(string title, bool isExpanded) { CoreEditorUtils.DrawSplitter(false); return(CoreEditorUtils.DrawHeaderFoldout(title, isExpanded, false)); }
public override void OnInspectorGUI() { serializedObject.Update(); Drawer_ToolBar(); EditorGUILayout.PropertyField(albedo, Styles.s_AlbedoLabel); EditorGUILayout.PropertyField(meanFreePath, Styles.s_MeanFreePathLabel); EditorGUILayout.Space(); CoreEditorUtils.DrawSplitter(); EditorGUI.BeginChangeCheck(); bool expendedVolume = CoreEditorUtils.DrawHeaderFoldout(Styles.k_VolumeHeader, GetExpendedAreas((uint)Expendable.Volume)); if (EditorGUI.EndChangeCheck()) { SetExpendedAreas((uint)Expendable.Volume, expendedVolume); } if (expendedVolume) { Drawer_AdvancedSwitch(); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(size, Styles.s_Size); if (EditorGUI.EndChangeCheck()) { Vector3 tmpClamp = size.vector3Value; tmpClamp.x = Mathf.Max(0f, tmpClamp.x); tmpClamp.y = Mathf.Max(0f, tmpClamp.y); tmpClamp.z = Mathf.Max(0f, tmpClamp.z); size.vector3Value = tmpClamp; } Vector3 s = size.vector3Value; EditorGUI.BeginChangeCheck(); if (advancedFade.boolValue) { Vector3 positive = positiveFade.vector3Value; positive.x *= s.x; positive.y *= s.y; positive.z *= s.z; Vector3 negative = negativeFade.vector3Value; negative.x *= s.x; negative.y *= s.y; negative.z *= s.z; EditorGUI.BeginChangeCheck(); CoreEditorUtils.DrawVector6(Styles.s_BlendLabel, ref positive, ref negative, Vector3.zero, s, InfluenceVolumeUI.k_HandlesColor); if (EditorGUI.EndChangeCheck()) { positive.x /= s.x; positive.y /= s.y; positive.z /= s.z; negative.x /= s.x; negative.y /= s.y; negative.z /= s.z; //forbid positive/negative box that doesn't intersect in inspector too for (int axis = 0; axis < 3; ++axis) { if (positive[axis] > 1f - negative[axis]) { if (positive == positiveFade.vector3Value) { negative[axis] = 1f - positive[axis]; } else { positive[axis] = 1f - negative[axis]; } } } positiveFade.vector3Value = positive; negativeFade.vector3Value = negative; } } else { EditorGUI.BeginChangeCheck(); float distanceMax = Mathf.Min(s.x, s.y, s.z); float uniformFadeDistance = uniformFade.floatValue * distanceMax; uniformFadeDistance = EditorGUILayout.FloatField(Styles.s_BlendLabel, uniformFadeDistance); if (EditorGUI.EndChangeCheck()) { uniformFade.floatValue = Mathf.Clamp(uniformFadeDistance / distanceMax, 0f, 0.5f); } } if (EditorGUI.EndChangeCheck()) { Vector3 posFade = new Vector3(); posFade.x = Mathf.Clamp01(positiveFade.vector3Value.x); posFade.y = Mathf.Clamp01(positiveFade.vector3Value.y); posFade.z = Mathf.Clamp01(positiveFade.vector3Value.z); Vector3 negFade = new Vector3(); negFade.x = Mathf.Clamp01(negativeFade.vector3Value.x); negFade.y = Mathf.Clamp01(negativeFade.vector3Value.y); negFade.z = Mathf.Clamp01(negativeFade.vector3Value.z); positiveFade.vector3Value = posFade; negativeFade.vector3Value = negFade; } EditorGUILayout.PropertyField(invertFade, Styles.s_InvertFadeLabel); EditorGUILayout.Space(); } CoreEditorUtils.DrawSplitter(); EditorGUI.BeginChangeCheck(); bool expendedDensityMaskTexture = CoreEditorUtils.DrawHeaderFoldout(Styles.k_DensityMaskTextureHeader, GetExpendedAreas((uint)Expendable.DensityMaskTexture)); if (EditorGUI.EndChangeCheck()) { SetExpendedAreas((uint)Expendable.DensityMaskTexture, expendedDensityMaskTexture); } if (expendedDensityMaskTexture) { EditorGUILayout.PropertyField(volumeTexture, Styles.s_VolumeTextureLabel); EditorGUILayout.PropertyField(textureScroll, Styles.s_TextureScrollLabel); EditorGUILayout.PropertyField(textureTile, Styles.s_TextureTileLabel); } serializedObject.ApplyModifiedProperties(); }