static void DrawDecalLayerNames(SerializedHDRenderPipelineGlobalSettings serialized, Editor owner) { m_ShowDecalLayerNames = CoreEditorUtils.DrawHeaderFoldout(Styles.decalLayersLabel, m_ShowDecalLayerNames, documentationURL: Documentation.GetPageLink(DocumentationUrls.k_DecalLayers), contextAction: pos => OnContextClickRenderingLayerNames(pos, serialized, section: 2)); if (m_ShowDecalLayerNames) { using (new EditorGUI.IndentLevelScope()) { using (var changed = new EditorGUI.ChangeCheckScope()) { EditorGUILayout.DelayedTextField(serialized.decalLayerName0, Styles.decalLayerName0); EditorGUILayout.DelayedTextField(serialized.decalLayerName1, Styles.decalLayerName1); EditorGUILayout.DelayedTextField(serialized.decalLayerName2, Styles.decalLayerName2); EditorGUILayout.DelayedTextField(serialized.decalLayerName3, Styles.decalLayerName3); EditorGUILayout.DelayedTextField(serialized.decalLayerName4, Styles.decalLayerName4); EditorGUILayout.DelayedTextField(serialized.decalLayerName5, Styles.decalLayerName5); EditorGUILayout.DelayedTextField(serialized.decalLayerName6, Styles.decalLayerName6); EditorGUILayout.DelayedTextField(serialized.decalLayerName7, Styles.decalLayerName7); if (changed.changed) { serialized.serializedObject?.ApplyModifiedProperties(); (serialized.serializedObject.targetObject as HDRenderPipelineGlobalSettings).UpdateRenderingLayerNames(); } } } } }
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(); }
// 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(); } } })); }
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; } }
/// <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(); } })); }
internal static bool DrawSectionFoldout(string title, bool isExpanded) { CoreEditorUtils.DrawSplitter(false); return(CoreEditorUtils.DrawHeaderFoldout(title, isExpanded, false)); }
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() { 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(); }
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(); }