private static void SetMaterialKeywords(Material material, EDStandardShaderGUI.WorkflowMode workflowMode) { EDStandardShaderGUI.SetKeyword(material, "_NORMALMAP", (bool)((UnityEngine.Object)material.GetTexture("_BumpMap")) || (bool)((UnityEngine.Object)material.GetTexture("_DetailNormalMap"))); if (workflowMode == EDStandardShaderGUI.WorkflowMode.Specular) { EDStandardShaderGUI.SetKeyword(material, "_SPECGLOSSMAP", (bool)((UnityEngine.Object)material.GetTexture("_SpecGlossMap"))); } else if (workflowMode == EDStandardShaderGUI.WorkflowMode.Metallic) { EDStandardShaderGUI.SetKeyword(material, "_METALLICGLOSSMAP", (bool)((UnityEngine.Object)material.GetTexture("_MetallicGlossMap"))); } EDStandardShaderGUI.SetKeyword(material, "_PARALLAXMAP", (bool)((UnityEngine.Object)material.GetTexture("_ParallaxMap"))); EDStandardShaderGUI.SetKeyword(material, "_DETAIL_MULX2", (bool)((UnityEngine.Object)material.GetTexture("_DetailAlbedoMap")) || (bool)((UnityEngine.Object)material.GetTexture("_DetailNormalMap"))); bool state = EDStandardShaderGUI.ShouldEmissionBeEnabled(material.GetColor("_EmissionColor")); EDStandardShaderGUI.SetKeyword(material, "_EMISSION", state); MaterialGlobalIlluminationFlags illuminationFlags1 = material.globalIlluminationFlags; if ((illuminationFlags1 & (MaterialGlobalIlluminationFlags.RealtimeEmissive | MaterialGlobalIlluminationFlags.BakedEmissive)) == MaterialGlobalIlluminationFlags.None) { return; } MaterialGlobalIlluminationFlags illuminationFlags2 = illuminationFlags1 & ~MaterialGlobalIlluminationFlags.EmissiveIsBlack; if (!state) { illuminationFlags2 |= MaterialGlobalIlluminationFlags.EmissiveIsBlack; } material.globalIlluminationFlags = illuminationFlags2; }
public override void AssignNewShaderToMaterial(Material material, Shader oldShader, Shader newShader) { base.AssignNewShaderToMaterial(material, oldShader, newShader); if ((UnityEngine.Object)oldShader == (UnityEngine.Object)null || !oldShader.name.Contains("Legacy Shaders/")) { return; } EDStandardShaderGUI.BlendMode blendMode = EDStandardShaderGUI.BlendMode.Opaque; if (oldShader.name.Contains("/Transparent/Cutout/")) { blendMode = EDStandardShaderGUI.BlendMode.Cutout; } else if (oldShader.name.Contains("/Transparent/")) { blendMode = EDStandardShaderGUI.BlendMode.Fade; } material.SetFloat("_Mode", (float)blendMode); Material[] materialArray = new Material[1]; int index = 0; Material material1 = material; materialArray[index] = material1; this.DetermineWorkflow(MaterialEditor.GetMaterialProperties((UnityEngine.Object[])materialArray)); EDStandardShaderGUI.MaterialChanged(material, this.m_WorkflowMode); }
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props) { this.FindProperties(props); this.m_MaterialEditor = materialEditor; Material material = materialEditor.target as Material; this.ShaderPropertiesGUI(material); if (!this.m_FirstTimeApply) { return; } EDStandardShaderGUI.SetMaterialKeywords(material, this.m_WorkflowMode); this.m_FirstTimeApply = false; }
public void ShaderPropertiesGUI(Material material) { EditorGUIUtility.labelWidth = 0.0f; EditorGUI.BeginChangeCheck(); this.BlendModePopup(); GUILayout.Label(EDStandardShaderGUI.Styles.primaryMapsText, EditorStyles.boldLabel, new GUILayoutOption[0]); this.DoAlbedoArea(material); this.DoGrungMaskArea(material); this.DoSpecularMetallicArea(); this.m_MaterialEditor.TexturePropertySingleLine(EDStandardShaderGUI.Styles.normalMapText, this.bumpMap, !((UnityEngine.Object) this.bumpMap.textureValue != (UnityEngine.Object)null) ? (MaterialProperty)null : this.bumpScale); this.m_MaterialEditor.TexturePropertySingleLine(EDStandardShaderGUI.Styles.heightMapText, this.heightMap, !((UnityEngine.Object) this.heightMap.textureValue != (UnityEngine.Object)null) ? (MaterialProperty)null : this.heigtMapScale); this.m_MaterialEditor.TexturePropertySingleLine(EDStandardShaderGUI.Styles.occlusionText, this.occlusionMap, !((UnityEngine.Object) this.occlusionMap.textureValue != (UnityEngine.Object)null) ? (MaterialProperty)null : this.occlusionStrength); this.DoEmissionArea(material); this.m_MaterialEditor.TexturePropertySingleLine(EDStandardShaderGUI.Styles.detailMaskText, this.detailMask); EditorGUI.BeginChangeCheck(); this.m_MaterialEditor.TextureScaleOffsetProperty(this.albedoMap); if (EditorGUI.EndChangeCheck()) { this.emissionMap.textureScaleAndOffset = this.albedoMap.textureScaleAndOffset; } EditorGUILayout.Space(); GUILayout.Label(EDStandardShaderGUI.Styles.secondaryMapsText, EditorStyles.boldLabel, new GUILayoutOption[0]); this.m_MaterialEditor.TexturePropertySingleLine(EDStandardShaderGUI.Styles.detailAlbedoText, this.detailAlbedoMap); this.m_MaterialEditor.TexturePropertySingleLine(EDStandardShaderGUI.Styles.detailNormalMapText, this.detailNormalMap, this.detailNormalMapScale); this.m_MaterialEditor.TextureScaleOffsetProperty(this.detailAlbedoMap); this.m_MaterialEditor.ShaderProperty(this.uvSetSecondary, EDStandardShaderGUI.Styles.uvSetLabel.text); if (!EditorGUI.EndChangeCheck()) { return; } foreach (Material material1 in this.blendMode.targets) { EDStandardShaderGUI.MaterialChanged(material1, this.m_WorkflowMode); } }
private void DoEmissionArea(Material material) { float maxColorComponent = this.emissionColorForRendering.colorValue.maxColorComponent; bool flag1 = !this.HasValidEmissiveKeyword(material); bool flag2 = (double)maxColorComponent > 0.0; bool flag3 = (UnityEngine.Object) this.emissionMap.textureValue != (UnityEngine.Object)null; this.m_MaterialEditor.TexturePropertyWithHDRColor(EDStandardShaderGUI.Styles.emissionText, this.emissionMap, this.emissionColorForRendering, this.m_ColorPickerHDRConfig, false); if ((UnityEngine.Object) this.emissionMap.textureValue != (UnityEngine.Object)null && !flag3 && (double)maxColorComponent <= 0.0) { this.emissionColorForRendering.colorValue = Color.white; } if (flag2) { EditorGUI.BeginDisabledGroup(!EDStandardShaderGUI.ShouldEmissionBeEnabled(this.emissionColorForRendering.colorValue)); this.m_MaterialEditor.LightmapEmissionProperty(3); EditorGUI.EndDisabledGroup(); } if (!flag1) { return; } EditorGUILayout.HelpBox(EDStandardShaderGUI.Styles.emissiveWarning.text, MessageType.Warning); }
private static void MaterialChanged(Material material, EDStandardShaderGUI.WorkflowMode workflowMode) { EDStandardShaderGUI.SetupMaterialWithBlendMode(material, (EDStandardShaderGUI.BlendMode)material.GetFloat("_Mode")); EDStandardShaderGUI.SetMaterialKeywords(material, workflowMode); }
private bool HasValidEmissiveKeyword(Material material) { return(material.IsKeywordEnabled("_EMISSION") || !EDStandardShaderGUI.ShouldEmissionBeEnabled(this.emissionColorForRendering.colorValue)); }