void DrawDecalGUI() { var material = materials[0]; bool affectAlbedo = material.HasProperty(kAffectAlbedo) && material.GetFloat(kAffectAlbedo) == 1.0f; bool affectNormal = material.HasProperty(kAffectNormal) && material.GetFloat(kAffectNormal) == 1.0f; bool affectMetal = material.HasProperty(kAffectMetal) && material.GetFloat(kAffectMetal) == 1.0f; bool affectSmoothness = material.HasProperty(kAffectSmoothness) && material.GetFloat(kAffectSmoothness) == 1.0f; bool affectAO = material.HasProperty(kAffectAO) && material.GetFloat(kAffectAO) == 1.0f; bool affectEmission = material.HasProperty(kAffectEmission) && material.GetFloat(kAffectEmission) == 1.0f; bool affectMaskmap = affectMetal || affectAO || affectSmoothness; bool perChannelMask = false; HDRenderPipelineAsset hdrp = HDRenderPipeline.currentAsset; if (hdrp != null) { perChannelMask = hdrp.currentPlatformRenderPipelineSettings.decalSettings.perChannelMask; } bool allMaskMap = materials.All(m => m.GetTexture(kMaskMap)); if (affectAlbedo) { materialEditor.TexturePropertySingleLine(Styles.baseColorText, baseColorMap, baseColor); } else { Color color = baseColor.colorValue; EditorGUI.BeginChangeCheck(); EditorGUI.showMixedValue = baseColor.hasMixedValue; color.a = EditorGUILayout.Slider(Styles.baseOpacityText, color.a, 0.0f, 1.0f); EditorGUI.showMixedValue = false; if (EditorGUI.EndChangeCheck()) { baseColor.colorValue = color; } } using (new EditorGUI.DisabledScope(!affectNormal)) { materialEditor.TexturePropertySingleLine(Styles.normalMapText, normalMap); if (materials.All(m => m.GetTexture(kNormalMap))) { EditorGUI.indentLevel++; materialEditor.PopupShaderProperty(normalBlendSrc, Styles.normalOpacityChannelText, allMaskMap ? blendSourceNames : blendSourceNamesNoMap); EditorGUI.indentLevel--; } } using (new EditorGUI.DisabledScope(!affectMaskmap)) { materialEditor.TexturePropertySingleLine(Styles.maskMapText, maskMap); EditorGUI.indentLevel++; if (allMaskMap) { if (perChannelMask) { using (new EditorGUI.DisabledScope(!affectMetal)) materialEditor.MinMaxShaderProperty(metallicRemapMin, metallicRemapMax, 0.0f, 1.0f, Styles.metallicRemappingText); using (new EditorGUI.DisabledScope(!affectAO)) materialEditor.MinMaxShaderProperty(AORemapMin, AORemapMax, 0.0f, 1.0f, Styles.aoRemappingText); } using (new EditorGUI.DisabledScope(!affectSmoothness)) materialEditor.MinMaxShaderProperty(smoothnessRemapMin, smoothnessRemapMax, 0.0f, 1.0f, Styles.smoothnessRemappingText); } else { if (perChannelMask) { using (new EditorGUI.DisabledScope(!affectMetal)) materialEditor.ShaderProperty(metallic, Styles.metallicText); using (new EditorGUI.DisabledScope(!affectAO)) materialEditor.ShaderProperty(AO, Styles.aoText); } using (new EditorGUI.DisabledScope(!affectSmoothness)) materialEditor.ShaderProperty(smoothness, Styles.smoothnessText); } materialEditor.PopupShaderProperty(maskBlendSrc, Styles.maskOpacityChannelText, allMaskMap ? blendSourceNames : blendSourceNamesNoMap); EditorGUI.indentLevel--; } bool useBlueScale = (affectMaskmap && maskBlendSrc.floatValue == (float)BlendSource.MaskMapBlue) || (affectNormal && normalBlendSrc.floatValue == (float)BlendSource.MaskMapBlue); using (new EditorGUI.DisabledScope(!useBlueScale)) materialEditor.ShaderProperty(maskMapBlueScale, allMaskMap ? Styles.maskMapBlueScaleText : Styles.opacityBlueScaleText); materialEditor.ShaderProperty(decalBlend, Styles.decalBlendText); using (new EditorGUI.DisabledScope(!affectEmission)) { EditorGUI.BeginChangeCheck(); materialEditor.ShaderProperty(useEmissiveIntensity, Styles.useEmissionIntensityText); bool updateEmissiveColor = EditorGUI.EndChangeCheck(); if (useEmissiveIntensity.floatValue == 0.0f) { EditorGUI.BeginChangeCheck(); EmissionUIBlock.DoEmissiveTextureProperty(materialEditor, emissiveColorMap, emissiveColorLDR); if (EditorGUI.EndChangeCheck() || updateEmissiveColor) { emissiveColor.colorValue = emissiveColorHDR.colorValue; } } else { EditorGUI.BeginChangeCheck(); EmissionUIBlock.DoEmissiveTextureProperty(materialEditor, emissiveColorMap, emissiveColorLDR); EmissionUIBlock.DoEmissiveIntensityGUI(materialEditor, emissiveIntensity, emissiveIntensityUnit); if (EditorGUI.EndChangeCheck() || updateEmissiveColor) { EmissionUIBlock.UpdateEmissiveColorFromIntensityAndEmissiveColorLDR(materialEditor, materials); } } materialEditor.ShaderProperty(emissiveExposureWeight, Styles.emissiveExposureWeightText); } }
void DrawDecalGUI() { bool perChannelMask = false; HDRenderPipelineAsset hdrp = HDRenderPipeline.currentAsset; if (hdrp != null) { perChannelMask = hdrp.currentPlatformRenderPipelineSettings.decalSettings.perChannelMask; } bool allMaskMap = materials.All(m => m.GetTexture(kMaskMap)); materialEditor.TexturePropertySingleLine((materials[0].GetFloat(kAffectAlbedo) == 1.0f) ? Styles.baseColorText : Styles.baseColorText2, baseColorMap, baseColor); materialEditor.TexturePropertySingleLine(Styles.normalMapText, normalMap); if (materials.All(m => m.GetTexture(kNormalMap))) { EditorGUI.indentLevel++; PopupShaderProperty(normalBlendSrc, Styles.normalOpacityChannelText, allMaskMap ? blendSourceNames : blendSourceNamesNoMap); EditorGUI.indentLevel--; } materialEditor.TexturePropertySingleLine(Styles.maskMapText, maskMap); EditorGUI.indentLevel++; if (allMaskMap) { if (perChannelMask) { MinMaxShaderProperty(metallicRemapMin, metallicRemapMax, 0.0f, 1.0f, Styles.metallicRemappingText); MinMaxShaderProperty(AORemapMin, AORemapMax, 0.0f, 1.0f, Styles.aoRemappingText); } MinMaxShaderProperty(smoothnessRemapMin, smoothnessRemapMax, 0.0f, 1.0f, Styles.smoothnessRemappingText); } else { if (perChannelMask) { materialEditor.ShaderProperty(metallic, Styles.metallicText); materialEditor.ShaderProperty(AO, Styles.aoText); } materialEditor.ShaderProperty(smoothness, Styles.smoothnessText); } PopupShaderProperty(maskBlendSrc, Styles.normalOpacityChannelText, allMaskMap ? blendSourceNames : blendSourceNamesNoMap); EditorGUI.indentLevel--; materialEditor.ShaderProperty(maskMapBlueScale, allMaskMap ? Styles.maskMapBlueScaleText : Styles.opacityBlueScaleText); materialEditor.ShaderProperty(decalBlend, Styles.decalBlendText); EditorGUI.BeginChangeCheck(); materialEditor.ShaderProperty(useEmissiveIntensity, Styles.useEmissionIntensityText); bool updateEmissiveColor = EditorGUI.EndChangeCheck(); if (useEmissiveIntensity.floatValue == 0.0f) { EditorGUI.BeginChangeCheck(); materialEditor.TexturePropertySingleLine(Styles.emissionMapText, emissiveColorMap, emissiveColorHDR); if (EditorGUI.EndChangeCheck() || updateEmissiveColor) { emissiveColor.colorValue = emissiveColorHDR.colorValue; } } else { EditorGUI.BeginChangeCheck(); materialEditor.TexturePropertySingleLine(Styles.emissionMapText, emissiveColorMap, emissiveColorLDR); EmissionUIBlock.DoEmissiveIntensityGUI(materialEditor, emissiveIntensity, emissiveIntensityUnit); if (EditorGUI.EndChangeCheck() || updateEmissiveColor) { EmissionUIBlock.UpdateEmissiveColorFromIntensityAndEmissiveColorLDR(materialEditor, materials); } } materialEditor.ShaderProperty(emissiveExposureWeight, Styles.emissiveExposureWeightText); }