bool ShaderPropertiesGUI(MaterialEditor materialEditor) { EditorGUI.BeginChangeCheck(); // albedo materialEditor.TexturePropertySingleLine(_albedoText, _mainTex, _color); // metallic / smoothness if (_metallicGlossMap.textureValue == null) materialEditor.TexturePropertyTwoLines(_metallicText, _metallicGlossMap, _metallic, _smoothnessText, _glossiness); else materialEditor.TexturePropertySingleLine(_metallicText, _metallicGlossMap); // normal map materialEditor.TexturePropertySingleLine(_normalMapText, _bumpMap, _bumpMap.textureValue != null ? _bumpScale : null); // occlusion materialEditor.TexturePropertySingleLine(_occlusionText, _occlusionMap, _occlusionMap.textureValue != null ? _occlusionStrength : null); // emission bool hadEmissionTexture = _emissionMap.textureValue != null; materialEditor.TexturePropertyWithHDRColor(_emissionText, _emissionMap, _emissionColor, _colorPickerHDRConfig, false); // if texture was assigned and color was black set color to white if (_emissionMap.textureValue != null && !hadEmissionTexture) if (_emissionColor.colorValue.maxColorComponent <= 0) _emissionColor.colorValue = Color.white; return EditorGUI.EndChangeCheck(); }
void DrawLayer(MaterialEditor editor, int i, MaterialProperty[] props, string[] keyWords, Workflow workflow, bool hasGloss, bool hasSpec, bool isParallax, bool hasEmis, bool hasDistBlend) { EditorGUIUtility.labelWidth = 0f; var albedoMap = FindProperty ("_Tex" + i, props); var tint = FindProperty("_Tint" + i, props); var normalMap = FindProperty ("_Normal" + i, props); var smoothness = FindProperty("_Glossiness" + i, props); var glossinessMap = FindProperty("_GlossinessTex" + i, props, false); var metallic = FindProperty("_Metallic" + i, props, false); var emissionTex = FindProperty("_Emissive" + i, props); var emissionMult = FindProperty("_EmissiveMult" + i, props); var parallax = FindProperty("_Parallax" + i, props); var texScale = FindProperty("_TexScale" + i, props); var specMap = FindProperty("_SpecGlossMap" + i, props, false); var specColor = FindProperty("_SpecColor" + i, props, false); var distUVScale = FindProperty("_DistUVScale" + i, props, false); editor.TexturePropertySingleLine(new GUIContent("Albedo/Height"), albedoMap); editor.ShaderProperty(tint, "Tint"); editor.TexturePropertySingleLine(new GUIContent("Normal"), normalMap); if (workflow == Workflow.Metallic) { editor.TexturePropertySingleLine(new GUIContent("Metal(R)/Smoothness(A)"), glossinessMap); } else { editor.TexturePropertySingleLine(new GUIContent("Specular(RGB)/Gloss(A)"), specMap); } if (workflow == Workflow.Metallic && !hasGloss) { editor.ShaderProperty(smoothness, "Smoothness"); editor.ShaderProperty(metallic, "Metallic"); } else if (workflow == Workflow.Specular && !hasSpec) { editor.ShaderProperty(smoothness, "Smoothness"); editor.ShaderProperty(specColor, "Specular Color"); } editor.TexturePropertySingleLine(new GUIContent("Emission"), emissionTex); editor.ShaderProperty(emissionMult, "Emissive Multiplier"); editor.ShaderProperty(texScale, "Texture Scale"); if (hasDistBlend) { editor.ShaderProperty(distUVScale, "Distance UV Scale"); } if (isParallax) { editor.ShaderProperty(parallax, "Parallax Height"); } if (i != 1) { editor.ShaderProperty(FindProperty("_Contrast"+i, props), "Interpolation Contrast"); } }
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props) { FindProperties (props); // MaterialProperties can be animated so we do not cache them but fetch them every event to ensure animated values are updated correctly // Use default labelWidth EditorGUIUtility.labelWidth = 0f; // Detect any changes to the material EditorGUI.BeginChangeCheck(); { GUILayout.Label (Styles.material0Header, EditorStyles.boldLabel); // Texture materialEditor.TexturePropertySingleLine (Styles.albedo, albedoMap); materialEditor.TexturePropertySingleLine (Styles.specular, specularMap); materialEditor.TexturePropertySingleLine (Styles.normal, bumpMap); materialEditor.TextureScaleOffsetProperty (albedoMap); GUILayout.Label (Styles.maskHeader, EditorStyles.boldLabel); materialEditor.TexturePropertySingleLine (Styles.blendMask, blendMask); materialEditor.TextureScaleOffsetProperty (blendMask); GUILayout.Label (Styles.material1Header, EditorStyles.boldLabel); materialEditor.TexturePropertySingleLine (Styles.albedo, albedoMap2); materialEditor.TexturePropertySingleLine (Styles.specular, specularMap2); materialEditor.TexturePropertySingleLine (Styles.normal, bumpMap2); materialEditor.TextureScaleOffsetProperty (albedoMap2); } }
bool ShaderPropertiesGUI(MaterialEditor materialEditor) { EditorGUI.BeginChangeCheck(); materialEditor.TexturePropertySingleLine(_textCubemap, _cubemap, _tint); Vector3Property(materialEditor, _euler, "Rotation"); materialEditor.ShaderProperty(_exposure, "Exposure"); materialEditor.ShaderProperty(_saturation, "Saturation"); return EditorGUI.EndChangeCheck(); }
bool ShaderPropertiesGUI(MaterialEditor materialEditor) { EditorGUI.BeginChangeCheck(); materialEditor.ShaderProperty(_colorMode, "Color Mode"); if (_colorMode.floatValue > 0) { var rect = EditorGUILayout.GetControlRect(); rect.x += EditorGUIUtility.labelWidth; rect.width = (rect.width - EditorGUIUtility.labelWidth) / 2 - 2; materialEditor.ShaderProperty(rect, _color, ""); rect.x += rect.width + 4; materialEditor.ShaderProperty(rect, _color2, ""); } else { materialEditor.ShaderProperty(_color, " "); } EditorGUILayout.Space(); materialEditor.ShaderProperty(_metallic, "Metallic"); materialEditor.ShaderProperty(_smoothness, "Smoothness"); EditorGUILayout.Space(); materialEditor.TexturePropertySingleLine(_albedoText, _albedoMap, null); materialEditor.TexturePropertySingleLine(_normalMapText, _normalMap, _normalMap.textureValue ? _normalScale : null); materialEditor.TexturePropertySingleLine(_occlusionText, _occlusionMap, _occlusionMap.textureValue ? _occlusionStr : null); materialEditor.TextureScaleOffsetProperty(_albedoMap); EditorGUILayout.Space(); materialEditor.ShaderProperty(_emission, "Emission"); EditorGUILayout.Space(); materialEditor.ShaderProperty(_randomUV, "Random UV"); return EditorGUI.EndChangeCheck(); }
bool ShaderPropertiesGUI(MaterialEditor materialEditor) { EditorGUI.BeginChangeCheck(); materialEditor.TexturePropertySingleLine(_albedoText, _albedoMap, _albedoColor); materialEditor.ShaderProperty(_metallic, "Metallic"); materialEditor.ShaderProperty(_smoothness, "Smoothness"); EditorGUILayout.Space(); materialEditor.TexturePropertySingleLine(_normalMapText, _bumpMap, null); EditorGUILayout.Space(); materialEditor.TexturePropertySingleLine(_occlusionText, _occlusionMap, _occlusionMap.textureValue ? _occlusionStrength : null); EditorGUILayout.Space(); materialEditor.ShaderProperty(_mapScale, "Mapping Scale"); return EditorGUI.EndChangeCheck(); }
bool ShaderPropertiesGUI(MaterialEditor materialEditor) { EditorGUI.BeginChangeCheck(); materialEditor.ShaderProperty(_color, "Color"); materialEditor.ShaderProperty(_metallic, "Metallic"); materialEditor.ShaderProperty(_smoothness, "Smoothness"); EditorGUILayout.Space(); materialEditor.TexturePropertySingleLine(_albedoText, _albedoMap, null); var scale = _normalMap.textureValue ? _normalScale : null; materialEditor.TexturePropertySingleLine(_normalMapText, _normalMap, scale); var str = _occlusionMap.textureValue ? _occlusionStr : null; materialEditor.TexturePropertySingleLine(_occlusionText, _occlusionMap, str); if (_albedoMap.textureValue || _normalMap.textureValue || _occlusionMap.textureValue) materialEditor.ShaderProperty(_mapScale, "Scale"); return EditorGUI.EndChangeCheck(); }
void DrawLayer(MaterialEditor editor, int i, MaterialProperty[] props, string[] keyWords, bool hasGloss, bool isParallax, bool hasEmis) { EditorGUIUtility.labelWidth = 0f; var albedoMap = FindProperty ("_Tex" + i, props); var normalMap = FindProperty ("_Normal" + i, props); var smoothness = FindProperty("_Glossiness" + i, props); var glossinessMap = FindProperty("_GlossinessTex" + i, props); var metallic = FindProperty("_Metallic" + i, props); var emissionTex = FindProperty("_Emissive" + i, props); var emissionMult = FindProperty("_EmissiveMult" + i, props); var parallax = FindProperty("_Parallax" + i, props); var texScale = FindProperty("_TexScale" + i, props); //editor.TexturePropertySingleLine("Albedo (RGB) Height (A)", albedoMap); editor.TexturePropertySingleLine(new GUIContent("Albedo/Height"), albedoMap); editor.TexturePropertySingleLine(new GUIContent("Normal"), normalMap); editor.TexturePropertySingleLine(new GUIContent("Metal(R)/Smoothness(A)"), glossinessMap); if (!hasGloss) { editor.ShaderProperty(smoothness, "Smoothness"); editor.ShaderProperty(metallic, "Metallic"); } editor.TexturePropertySingleLine(new GUIContent("Emission"), emissionTex); editor.ShaderProperty(emissionMult, "Emissive Multiplier"); editor.ShaderProperty(texScale, "Texture Scale"); if (isParallax) { editor.ShaderProperty(parallax, "Parallax Height"); } if (i != 1) { editor.ShaderProperty(FindProperty("_Contrast"+i, props), "Interpolation Contrast"); } }
bool ShaderPropertiesGUI(MaterialEditor materialEditor) { EditorGUI.BeginChangeCheck(); materialEditor.TexturePropertySingleLine(_textCubemap, _cubemap, _tint); Vector3Property(materialEditor, _euler, "Rotation"); materialEditor.ShaderProperty(_exposure, "Exposure"); materialEditor.ShaderProperty(_saturation, "Saturation"); materialEditor.ShaderProperty(_lod, "Specify MIP Level"); if (_lod.hasMixedValue || _lod.floatValue > 0) { EditorGUI.indentLevel++; materialEditor.ShaderProperty(_lodLevel, "Level"); EditorGUI.indentLevel--; } return EditorGUI.EndChangeCheck(); }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; // Detect any changes to the material EditorGUI.BeginChangeCheck(); { CullModePopup(); BlendModePopup(); OrthoNormalizeToggle(); // Primary properties DoAlbedoArea(material); //高光 DoSpecularMetallicArea(); //外发光 DoRimArea(material); m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, bumpMap, bumpMap.textureValue != null ? bumpScale : null); m_MaterialEditor.TexturePropertySingleLine(Styles.occlusionText, occlusionMap, occlusionMap.textureValue != null ? occlusionStrength : null); DoEmissionArea(material); EditorGUI.BeginChangeCheck(); m_MaterialEditor.TextureScaleOffsetProperty(albedoMap); // Apply the main texture scale and offset to the emission texture as well, for Enlighten's sake if (EditorGUI.EndChangeCheck()) { emissionMap.textureScaleAndOffset = albedoMap.textureScaleAndOffset; } EditorGUILayout.Space(); } if (EditorGUI.EndChangeCheck()) { foreach (var obj in blendMode.targets) { MaterialChanged((Material)obj, m_WorkflowMode); } } }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; // Detect any changes to the material EditorGUI.BeginChangeCheck(); { GUILayout.Label(Styles.tessellationText, EditorStyles.boldLabel); if (m_WorkflowMode == WorkflowMode.Distance) { m_MaterialEditor.ShaderProperty(tessellation, Styles.tessFacText.text); m_MaterialEditor.ShaderProperty(maxdist, Styles.tessMaxText.text); } else { m_MaterialEditor.ShaderProperty(tessellation, Styles.edgelenText.text); } m_MaterialEditor.ShaderProperty(tessphong, Styles.tessPhongText.text); EditorGUILayout.Space(); GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel); if (!hasDispTexture) { m_MaterialEditor.TexturePropertySingleLine(Styles.albedoText2, albedoMap, albedoColor); } else { m_MaterialEditor.TexturePropertySingleLine(Styles.albedoText, albedoMap, albedoColor); } m_MaterialEditor.TextureScaleOffsetProperty(albedoMap); m_MaterialEditor.TexturePropertySingleLine(Styles.dispmapText, dispMap); m_MaterialEditor.TextureScaleOffsetProperty(dispMap); m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, bumpMap, bumpMap.textureValue != null ? bumpScale : null); m_MaterialEditor.TextureScaleOffsetProperty(bumpMap); EditorGUILayout.Space(); GUILayout.Label(Styles.displacementText, EditorStyles.boldLabel); m_MaterialEditor.ShaderProperty(displacement, Styles.dispScaleText.text); m_MaterialEditor.ShaderProperty(dispoffset, Styles.dispOffsetText.text); if (!hasDispTexture) { m_MaterialEditor.ShaderProperty(displacementto, Styles.dispTileText.text); } else { GUILayout.Label(Styles.displacementText, EditorStyles.boldLabel); } EditorGUILayout.Space(); GUILayout.Label(Styles.matParamsText, EditorStyles.boldLabel); m_MaterialEditor.ShaderProperty(metallic, Styles.metallicText.text); m_MaterialEditor.ShaderProperty(smoothness, Styles.smoothnessText.text); m_MaterialEditor.ShaderProperty(specburn, Styles.specBurnText.text); m_MaterialEditor.ShaderProperty(specao, Styles.specularAOText.text); m_MaterialEditor.ShaderProperty(diffuseao, Styles.diffuseAOText.text); m_MaterialEditor.ShaderProperty(giao, Styles.giAOText.text); EditorGUILayout.Space(); GUILayout.Label(Styles.secondaryMapsText, EditorStyles.boldLabel); m_MaterialEditor.TexturePropertySingleLine(Styles.detailAlbedoText, detailAlbedoMap); m_MaterialEditor.TexturePropertySingleLine(Styles.detailNormalMapText, detailNormalMap, detailNormalMapScale); m_MaterialEditor.ShaderProperty(detailao, Styles.detailAOText.text); m_MaterialEditor.TextureScaleOffsetProperty(detailAlbedoMap); //m_MaterialEditor.ShaderProperty(uvSetSecondary, Styles.uvSetLabel.text); SetKeywords(material); } }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; // Detect any changes to the material EditorGUI.BeginChangeCheck(); { BlendModePopup(); // Primary properties GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel); DoAlbedoArea(material); m_MaterialEditor.TexturePropertySingleLine(Styles.metallicMapText, metallicMap, metallicMap.textureValue != null ? null : metallic); m_MaterialEditor.TexturePropertySingleLine(Styles.roughnessText, roughnessMap, roughnessMap.textureValue != null ? null : roughness); m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, bumpMap, bumpMap.textureValue != null ? bumpScale : null); m_MaterialEditor.TexturePropertySingleLine(Styles.heightMapText, heightMap, heightMap.textureValue != null ? heigtMapScale : null); m_MaterialEditor.TexturePropertySingleLine(Styles.occlusionText, occlusionMap, occlusionMap.textureValue != null ? occlusionStrength : null); m_MaterialEditor.TexturePropertySingleLine(Styles.detailMaskText, detailMask); DoEmissionArea(material); EditorGUI.BeginChangeCheck(); m_MaterialEditor.TextureScaleOffsetProperty(albedoMap); if (EditorGUI.EndChangeCheck()) { emissionMap.textureScaleAndOffset = albedoMap.textureScaleAndOffset; // Apply the main texture scale and offset to the emission texture as well, for Enlighten's sake } EditorGUILayout.Space(); // Secondary properties GUILayout.Label(Styles.secondaryMapsText, EditorStyles.boldLabel); m_MaterialEditor.TexturePropertySingleLine(Styles.detailAlbedoText, detailAlbedoMap); m_MaterialEditor.TexturePropertySingleLine(Styles.detailNormalMapText, detailNormalMap, detailNormalMapScale); m_MaterialEditor.TextureScaleOffsetProperty(detailAlbedoMap); m_MaterialEditor.ShaderProperty(uvSetSecondary, Styles.uvSetLabel.text); m_MaterialEditor.ColorProperty(sectionColor, "_SectionColor"); if (inverse != null) { m_MaterialEditor.ShaderProperty(inverse, Styles.inverseText); } if (stencilMask != null) { m_MaterialEditor.RangeProperty(stencilMask, "_StencilMask"); } // Third properties GUILayout.Label(Styles.forwardText, EditorStyles.boldLabel); if (highlights != null) { m_MaterialEditor.ShaderProperty(highlights, Styles.highlightsText); } if (reflections != null) { m_MaterialEditor.ShaderProperty(reflections, Styles.reflectionsText); } EditorGUILayout.Space(); if (retractBackfaces != null) { m_MaterialEditor.ShaderProperty(retractBackfaces, Styles.retractBackfacesText); } } if (EditorGUI.EndChangeCheck()) { foreach (var obj in blendMode.targets) { MaterialChanged((Material)obj); } } EditorGUILayout.Space(); // NB renderqueue editor is not shown on purpose: we want to override it based on blend mode GUILayout.Label(Styles.advancedText, EditorStyles.boldLabel); m_MaterialEditor.EnableInstancingField(); }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; // Detect any changes to the material EditorGUI.BeginChangeCheck(); { BlendModePopup(); // Primary properties GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel); DoAlbedoArea(material); DoSpecularMetallicArea(); m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, bumpMap, bumpMap.textureValue != null ? bumpScale : null); m_MaterialEditor.TexturePropertySingleLine(Styles.heightMapText, heightMap, heightMap.textureValue != null ? heigtMapScale : null); m_MaterialEditor.TexturePropertySingleLine(Styles.occlusionText, occlusionMap, occlusionMap.textureValue != null ? occlusionStrength : null); DoEmissionArea(material); m_MaterialEditor.TexturePropertySingleLine(Styles.detailMaskText, detailMask); EditorGUI.BeginChangeCheck(); m_MaterialEditor.TextureScaleOffsetProperty(albedoMap); if (EditorGUI.EndChangeCheck()) { emissionMap.textureScaleAndOffset = albedoMap.textureScaleAndOffset; // Apply the main texture scale and offset to the emission texture as well, for Enlighten's sake } EditorGUILayout.Space(); // Secondary properties GUILayout.Label(Styles.secondaryMapsText, EditorStyles.boldLabel); m_MaterialEditor.TexturePropertySingleLine(Styles.detailAlbedoText, detailAlbedoMap); m_MaterialEditor.TexturePropertySingleLine(Styles.detailNormalMapText, detailNormalMap, detailNormalMapScale); m_MaterialEditor.TextureScaleOffsetProperty(detailAlbedoMap); m_MaterialEditor.ShaderProperty(uvSetSecondary, Styles.uvSetLabel.text); // Third properties GUILayout.Label(Styles.forwardText, EditorStyles.boldLabel); if (highlights != null) { m_MaterialEditor.ShaderProperty(highlights, Styles.highlightsText); } if (reflections != null) { m_MaterialEditor.ShaderProperty(reflections, Styles.reflectionsText); } GUILayout.Label(Styles.bakeryText, EditorStyles.boldLabel); m_MaterialEditor.ShaderProperty(enableDoubleSidedOn, Styles.doubleSidedLabel); enableDoubleSided.floatValue = enableDoubleSidedOn.floatValue > 0 ? 0 : 2; m_MaterialEditor.ShaderProperty(enableVertexLM, Styles.vertexLMLabel); if (enableVertexLM.floatValue > 0) { m_MaterialEditor.ShaderProperty(enableVertexLMdir, Styles.vertexLMdirLabel); //if (enableVertexLMdir.floatValue > 0) enableVertexLMSH.floatValue = 0; } if (enableVertexLM.floatValue > 0) { m_MaterialEditor.ShaderProperty(enableVertexLMSH, Styles.vertexLMSHLabel); //if (enableVertexLMSH.floatValue > 0) enableVertexLMdir.floatValue = 0; } if (enableVertexLM.floatValue > 0) { m_MaterialEditor.ShaderProperty(enableVertexLMmask, Styles.vertexLMMaskLabel); } m_MaterialEditor.ShaderProperty(enableRNM, Styles.rnmLabel); m_MaterialEditor.ShaderProperty(enableSH, Styles.shLabel); if (enableSH.floatValue > 0 || enableVertexLMSH.floatValue > 0) { m_MaterialEditor.ShaderProperty(enableSHN, Styles.shnLabel); } m_MaterialEditor.ShaderProperty(enableSpec, Styles.specLabel); m_MaterialEditor.ShaderProperty(enableBicubic, Styles.bicubicLabel); m_MaterialEditor.ShaderProperty(enablePSHN, Styles.pshnLabel); EditorGUILayout.Space(); } if (EditorGUI.EndChangeCheck()) { foreach (var obj in blendMode.targets) { MaterialChanged((Material)obj, m_WorkflowMode); } } }
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties) { if (m_FirstTimeApply) { foreach (var obj in materialEditor.targets) { MaterialChanged((Material)obj); } m_FirstTimeApply = false; } // Use default labelWidth EditorGUIUtility.labelWidth = 0.0f; EditorGUI.BeginChangeCheck(); { GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel); // color var colorTexProp = ShaderGUI.FindProperty("_MainTex", properties); var colorProp = ShaderGUI.FindProperty("_Color", properties); materialEditor.TexturePropertySingleLine(Styles.colorText, colorTexProp, null, colorProp); // normal var normalTexProp = ShaderGUI.FindProperty("_BumpMap", properties); materialEditor.TexturePropertySingleLine(Styles.normalMapText, normalTexProp); // extra var extraTexProp = ShaderGUI.FindProperty("_ExtraTex", properties); materialEditor.TexturePropertySingleLine(Styles.extraMapText, extraTexProp, null); if (extraTexProp.textureValue == null) { var glossProp = ShaderGUI.FindProperty("_Glossiness", properties); materialEditor.ShaderProperty(glossProp, Styles.smoothnessText, 2); var metallicProp = ShaderGUI.FindProperty("_Metallic", properties); materialEditor.ShaderProperty(metallicProp, Styles.metallicText, 2); } // subsurface var ssTexProp = ShaderGUI.FindProperty("_SubsurfaceTex", properties); var ssProp = ShaderGUI.FindProperty("_SubsurfaceColor", properties); materialEditor.TexturePropertySingleLine(Styles.subsurfaceMapText, ssTexProp, null, ssProp); // Emission emissionColorForRendering = ShaderGUI.FindProperty("_EmissionColor", properties); emissionMap = ShaderGUI.FindProperty("_EmissionMap", properties); emissionMap.textureScaleAndOffset = colorTexProp.textureScaleAndOffset; // other options EditorGUILayout.Space(); GUILayout.Label(Styles.optionsText, EditorStyles.boldLabel); MakeAlignedProperty(FindProperty("_TwoSided", properties), Styles.twoSidedText, materialEditor, true); MakeAlignedProperty(FindProperty("_WindQuality", properties), Styles.windQualityText, materialEditor, true); MakeCheckedProperty(FindProperty("_HueVariationKwToggle", properties), FindProperty("_HueVariationColor", properties), Styles.hueVariationText, materialEditor); MakeAlignedProperty(FindProperty("_NormalMapKwToggle", properties), Styles.normalMappingText, materialEditor, true); // subsurface var subsurfaceToggle = FindProperty("_SubsurfaceKwToggle", properties); MakeAlignedProperty(subsurfaceToggle, Styles.subsurfaceText, materialEditor, true); if (subsurfaceToggle.floatValue > 0.0f) { var sssIndirectProp = ShaderGUI.FindProperty("_SubsurfaceIndirect", properties); materialEditor.ShaderProperty(sssIndirectProp, Styles.subsurfaceIndirectText, 2); } // billboard var billboardToggle = FindProperty("_BillboardKwToggle", properties); MakeAlignedProperty(billboardToggle, Styles.billboardText, materialEditor, true); if (billboardToggle.floatValue > 0.0f) { var prop = ShaderGUI.FindProperty("_BillboardShadowFade", properties); materialEditor.ShaderProperty(prop, Styles.billboardShadowFadeText, 2); } } if (EditorGUI.EndChangeCheck()) { foreach (var obj in materialEditor.targets) { Material mat = (Material)obj; MaterialChanged(mat); } } EditorGUILayout.Space(); GUILayout.Label(Styles.advancedText, EditorStyles.boldLabel); materialEditor.EnableInstancingField(); materialEditor.DoubleSidedGIField(); // Emission for GI? m_MaterialEditor = materialEditor; if (materialEditor.EmissionEnabledProperty()) { bool hadEmissionTexture = emissionMap.textureValue != null; // Texture and HDR color controls m_MaterialEditor.TexturePropertyWithHDRColor(Styles.emissionText, emissionMap, emissionColorForRendering, false); // If texture was assigned and color was black set color to white float brightness = emissionColorForRendering.colorValue.maxColorComponent; if (emissionMap.textureValue != null && !hadEmissionTexture && brightness <= 0f) { emissionColorForRendering.colorValue = Color.white; } // change the GI flag and fix it up with emissive as black if necessary m_MaterialEditor.LightmapEmissionFlagsProperty(MaterialEditor.kMiniTextureFieldLabelIndentLevel, true); SetKeyword((Material)m_MaterialEditor.target, "EFFECT_EMISSION", true); } else { SetKeyword((Material)m_MaterialEditor.target, "EFFECT_EMISSION", false); } }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; // Detect any changes to the material EditorGUI.BeginChangeCheck(); { //$$$-------------------------------------- GUILayout.BeginHorizontal(); GUILayout.Label("Render queue: ", GUILayout.Width(100)); EditorGUI.BeginChangeCheck(); Styles.renderQueue = material.renderQueue - (int)RenderQueue.AlphaTest; Styles.renderQueue = (int)GUILayout.HorizontalSlider(Styles.renderQueue, 0, 50); int.TryParse(GUILayout.TextField(Styles.renderQueue.ToString(), GUILayout.Width(30)), out Styles.renderQueue); if (EditorGUI.EndChangeCheck()) { material.renderQueue = (int)RenderQueue.AlphaTest + Styles.renderQueue; } GUILayout.EndHorizontal(); EditorGUI.BeginChangeCheck(); Styles.zWrite = GUILayout.Toggle(Styles.zWrite, "Write into ZBuffer "); if (EditorGUI.EndChangeCheck()) { if (Styles.zWrite) { material.SetInt("_ZWrite", 1); } else { material.SetInt("_ZWrite", 0); } } //BlendModePopup(); //$$$-------------------------------------- // Primary properties GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel); DoAlbedoArea(material); //$$$-------------------------------------- m_MaterialEditor.ShaderProperty(overalAlpha, Styles.overalAlphaText.text, MaterialEditor.kMiniTextureFieldLabelIndentLevel - 1); m_MaterialEditor.ShaderProperty(diffuseAlpha, Styles.diffuseAlphaText.text, MaterialEditor.kMiniTextureFieldLabelIndentLevel - 1); //$$$-------------------------------------- DoSpecularMetallicArea(); //$$$-------------------------------------- m_MaterialEditor.ShaderProperty(specularAlpha, Styles.specularAlphaText.text, MaterialEditor.kMiniTextureFieldLabelIndentLevel - 1); m_MaterialEditor.ShaderProperty(smoothnessAlpha, Styles.smoothnessAlphaText.text, MaterialEditor.kMiniTextureFieldLabelIndentLevel - 1); //$$$-------------------------------------- m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, bumpMap, bumpMap.textureValue != null ? bumpScale : null); //$$$-------------------------------------- m_MaterialEditor.ShaderProperty(normalAlpha, Styles.normalAlphaText.text, MaterialEditor.kMiniTextureFieldLabelIndentLevel - 1); //$$$-------------------------------------- m_MaterialEditor.TexturePropertySingleLine(Styles.heightMapText, heightMap, heightMap.textureValue != null ? heigtMapScale : null); m_MaterialEditor.TexturePropertySingleLine(Styles.occlusionText, occlusionMap, occlusionMap.textureValue != null ? occlusionStrength : null); //$$$-------------------------------------- m_MaterialEditor.ShaderProperty(occlusionAlpha, Styles.occlusionAlphaText.text, MaterialEditor.kMiniTextureFieldLabelIndentLevel - 1); //$$$-------------------------------------- m_MaterialEditor.TexturePropertySingleLine(Styles.detailMaskText, detailMask); DoEmissionArea(material); EditorGUI.BeginChangeCheck(); m_MaterialEditor.TextureScaleOffsetProperty(albedoMap); if (EditorGUI.EndChangeCheck()) { emissionMap.textureScaleAndOffset = albedoMap.textureScaleAndOffset; // Apply the main texture scale and offset to the emission texture as well, for Enlighten's sake } EditorGUILayout.Space(); // Secondary properties GUILayout.Label(Styles.secondaryMapsText, EditorStyles.boldLabel); m_MaterialEditor.TexturePropertySingleLine(Styles.detailAlbedoText, detailAlbedoMap); m_MaterialEditor.TexturePropertySingleLine(Styles.detailNormalMapText, detailNormalMap, detailNormalMapScale); m_MaterialEditor.TextureScaleOffsetProperty(detailAlbedoMap); m_MaterialEditor.ShaderProperty(uvSetSecondary, Styles.uvSetLabel.text); // Third properties GUILayout.Label(Styles.forwardText, EditorStyles.boldLabel); if (highlights != null) { m_MaterialEditor.ShaderProperty(highlights, Styles.highlightsText); } if (reflections != null) { m_MaterialEditor.ShaderProperty(reflections, Styles.reflectionsText); } } if (EditorGUI.EndChangeCheck()) { foreach (var obj in blendMode.targets) { MaterialChanged((Material)obj, m_WorkflowMode); } } EditorGUILayout.Space(); // NB renderqueue editor is not shown on purpose: we want to override it based on blend mode GUILayout.Label(Styles.advancedText, EditorStyles.boldLabel); m_MaterialEditor.EnableInstancingField(); m_MaterialEditor.DoubleSidedGIField(); }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; // Detect any changes to the material EditorGUI.BeginChangeCheck(); { BlendModePopup(); // Primary properties GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel); DoAlbedoArea(material); DoSpecularMetallicArea(); m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, bumpMap, bumpMap.textureValue != null ? bumpScale : null); m_MaterialEditor.TexturePropertySingleLine(Styles.heightMapText, heightMap, heightMap.textureValue != null ? heigtMapScale : null); m_MaterialEditor.TexturePropertySingleLine(Styles.occlusionText, occlusionMap, occlusionMap.textureValue != null ? occlusionStrength : null); DoEmissionArea(material); m_MaterialEditor.TexturePropertySingleLine(Styles.detailMaskText, detailMask); EditorGUI.BeginChangeCheck(); m_MaterialEditor.TextureScaleOffsetProperty(albedoMap); if (EditorGUI.EndChangeCheck()) { emissionMap.textureScaleAndOffset = albedoMap.textureScaleAndOffset; // Apply the main texture scale and offset to the emission texture as well, for Enlighten's sake } EditorGUILayout.Space(); // Secondary properties GUILayout.Label(Styles.secondaryMapsText, EditorStyles.boldLabel); m_MaterialEditor.TexturePropertySingleLine(Styles.detailAlbedoText, detailAlbedoMap); m_MaterialEditor.TexturePropertySingleLine(Styles.detailNormalMapText, detailNormalMap, detailNormalMapScale); m_MaterialEditor.TextureScaleOffsetProperty(detailAlbedoMap); m_MaterialEditor.ShaderProperty(uvSetSecondary, Styles.uvSetLabel.text); // RTP - geom blend EditorGUILayout.Space(); GUILayout.Label(Styles.geomBlendSectionText, EditorStyles.boldLabel); m_MaterialEditor.TexturePropertySingleLine(Styles._TERRAIN_HeightMapText, _TERRAIN_HeightMap); m_MaterialEditor.TexturePropertySingleLine(Styles._TERRAIN_ControlText, _TERRAIN_Control); m_MaterialEditor.ShaderProperty(_TERRAIN_PosSize, Styles._TERRAIN_PosSizeText.text); m_MaterialEditor.ShaderProperty(_TERRAIN_Tiling, Styles._TERRAIN_TilingText.text); } if (EditorGUI.EndChangeCheck()) { foreach (var obj in blendMode.targets) { MaterialChanged((Material)obj, m_WorkflowMode); } } }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; // Detect any changes to the material EditorGUI.BeginChangeCheck(); { BlendModePopup(); // Primary properties GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel); DoAlbedoArea(material); DoSpecularMetallicArea(); m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, bumpMap, bumpMap.textureValue != null ? bumpScale : null); m_MaterialEditor.TexturePropertySingleLine(Styles.heightMapText, heightMap, heightMap.textureValue != null ? heigtMapScale : null); m_MaterialEditor.TexturePropertySingleLine(Styles.occlusionText, occlusionMap, occlusionMap.textureValue != null ? occlusionStrength : null); DoEmissionArea(material); m_MaterialEditor.TexturePropertySingleLine(Styles.detailMaskText, detailMask); EditorGUI.BeginChangeCheck(); m_MaterialEditor.TextureScaleOffsetProperty(albedoMap); if (EditorGUI.EndChangeCheck()) { emissionMap.textureScaleAndOffset = albedoMap.textureScaleAndOffset; // Apply the main texture scale and offset to the emission texture as well, for Enlighten's sake } EditorGUILayout.Space(); // Secondary properties GUILayout.Label(Styles.secondaryMapsText, EditorStyles.boldLabel); m_MaterialEditor.TexturePropertySingleLine(Styles.detailAlbedoText, detailAlbedoMap); m_MaterialEditor.TexturePropertySingleLine(Styles.detailNormalMapText, detailNormalMap, detailNormalMapScale); m_MaterialEditor.TextureScaleOffsetProperty(detailAlbedoMap); m_MaterialEditor.ShaderProperty(uvSetSecondary, Styles.uvSetLabel.text); EditorGUILayout.Space(); //terrain blending properties m_MaterialEditor.TexturePropertySingleLine(Styles.terrainAlbedoText, terrainalbedo); m_MaterialEditor.TexturePropertySingleLine(Styles.terrainBumpText, terrainbump); m_MaterialEditor.ColorProperty(colorcorrection, Styles.ColorCorrectionText.text); m_MaterialEditor.FloatProperty(terrainglossiness, Styles.terrainGlossinessText.text); m_MaterialEditor.FloatProperty(terrainmetallic, Styles.terrainMetallicText.text); m_MaterialEditor.FloatProperty(terrainblend, Styles.BlendText.text); m_MaterialEditor.FloatProperty(terrainblendoffset, Styles.BlendOffsetText.text); } if (EditorGUI.EndChangeCheck()) { foreach (var obj in blendMode.targets) { MaterialChanged((Material)obj, m_WorkflowMode); } } }
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties) { // Use default labelWidth EditorGUIUtility.labelWidth = 0.0f; { GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel); // color var colorTexProp = ShaderGUI.FindProperty("_MainTex", properties); var colorProp = ShaderGUI.FindProperty("_Color", properties); materialEditor.TexturePropertySingleLine(Styles.colorText, colorTexProp, null, colorProp); // normal var normalTexProp = ShaderGUI.FindProperty("_BumpMap", properties); materialEditor.TexturePropertySingleLine(Styles.normalMapText, normalTexProp); // extra var extraTexProp = ShaderGUI.FindProperty("_ExtraTex", properties); materialEditor.TexturePropertySingleLine(Styles.extraMapText, extraTexProp, null); if (extraTexProp.textureValue == null) { var glossProp = ShaderGUI.FindProperty("_Glossiness", properties); materialEditor.ShaderProperty(glossProp, Styles.smoothnessText, 2); var metallicProp = ShaderGUI.FindProperty("_Metallic", properties); materialEditor.ShaderProperty(metallicProp, Styles.metallicText, 2); } // subsurface var ssTexProp = ShaderGUI.FindProperty("_SubsurfaceTex", properties); var ssProp = ShaderGUI.FindProperty("_SubsurfaceColor", properties); materialEditor.TexturePropertySingleLine(Styles.subsurfaceMapText, ssTexProp, null, ssProp); // other options EditorGUILayout.Space(); GUILayout.Label(Styles.optionsText, EditorStyles.boldLabel); MakeAlignedProperty(FindProperty("_TwoSided", properties), Styles.twoSidedText, materialEditor, true); MakeAlignedProperty(FindProperty("_WindQuality", properties), Styles.windQualityText, materialEditor, true); MakeCheckedProperty(FindProperty("_HueVariationKwToggle", properties), FindProperty("_HueVariationColor", properties), Styles.hueVariationText, materialEditor); MakeAlignedProperty(FindProperty("_NormalMapKwToggle", properties), Styles.normalMappingText, materialEditor, true); // subsurface var subsurfaceToggle = FindProperty("_SubsurfaceKwToggle", properties); MakeAlignedProperty(subsurfaceToggle, Styles.subsurfaceText, materialEditor, true); if (subsurfaceToggle.floatValue > 0.0f) { var sssIndirectProp = ShaderGUI.FindProperty("_SubsurfaceIndirect", properties); materialEditor.ShaderProperty(sssIndirectProp, Styles.subsurfaceIndirectText, 2); } // billboard var billboardToggle = FindProperty("_BillboardKwToggle", properties); MakeAlignedProperty(billboardToggle, Styles.billboardText, materialEditor, true); if (billboardToggle.floatValue > 0.0f) { var prop = ShaderGUI.FindProperty("_BillboardShadowFade", properties); materialEditor.ShaderProperty(prop, Styles.billboardShadowFadeText, 2); } } EditorGUILayout.Space(); GUILayout.Label(Styles.advancedText, EditorStyles.boldLabel); materialEditor.EnableInstancingField(); materialEditor.DoubleSidedGIField(); }
//GUI update public void ShaderPropertiesGUI(Material material) { EditorGUIUtility.labelWidth = 0f; int indentation = 0; m_MaterialEditor.RenderQueueField(); m_MaterialEditor.EnableInstancingField(); indentation = 1; if (imageType.floatValue == 0) { //Mask EditorGUI.BeginChangeCheck(); m_MaterialEditor.ShaderProperty(imageType, Styles.imageTypeText); m_MaterialEditor.ShaderProperty(maskBlendMode, Styles.maskBlendModeText, indentation); m_MaterialEditor.ShaderProperty(showMaskImage, Styles.showMaskImageText, indentation); if (EditorGUI.EndChangeCheck()) { UpdateAlphaBlendMode(material); if (maskBlendMode.floatValue == (int)MaskBlend.Customize) { _isBlendOpen = true; } } } else { //Image EditorGUI.BeginChangeCheck(); m_MaterialEditor.ShaderProperty(imageType, Styles.imageTypeText); m_MaterialEditor.ShaderProperty(imageBlendMode, Styles.imageBlendModeText, indentation); if (EditorGUI.EndChangeCheck()) { UpdateColorBlendMode(material); if (imageBlendMode.floatValue == (int)ImageBlend.Customize) { _isBlendOpen = true; } } } m_MaterialEditor.ShaderProperty(multiplyAlpha, Styles.multiplyAlphaText, indentation); //BlendMode bool isBlendFoldoutOpne = EditorGUILayout.Foldout(_isBlendOpen, "BlendMode"); if (_isBlendOpen != isBlendFoldoutOpne) { _isBlendOpen = isBlendFoldoutOpne; } if (isBlendFoldoutOpne) { EditorGUI.BeginChangeCheck(); m_MaterialEditor.ShaderProperty(blendSrc, Styles.blendSrcText, indentation); m_MaterialEditor.ShaderProperty(blendDst, Styles.blendDstText, indentation); m_MaterialEditor.ShaderProperty(blendAlphaSrc, Styles.blendAlphaSrcText, indentation); m_MaterialEditor.ShaderProperty(blendAlphaDst, Styles.blendAlphaDstText, indentation); m_MaterialEditor.ShaderProperty(blendColorOp, Styles.blendColorOpText, indentation); m_MaterialEditor.ShaderProperty(blendAlphaOp, Styles.blendAlphaOpText, indentation); if (EditorGUI.EndChangeCheck()) { material.SetFloat("_ImageBlendMode", (float)ImageBlend.Customize); material.SetFloat("_MaskBlendMode", (float)MaskBlend.Customize); } } indentation = 0; m_MaterialEditor.ShaderProperty(useAlphaMaskMap, Styles.useAlphaMaskMapText, indentation); if (useAlphaMaskMap.floatValue != 0) { m_MaterialEditor.TexturePropertySingleLine(Styles.alphaMaskMapText, alphaMaskMap); m_MaterialEditor.TextureScaleOffsetProperty(alphaMaskMap); } //MaskSetting m_MaterialEditor.ShaderProperty(useMaskChannel, Styles.useMaskChannelText, indentation); m_MaterialEditor.ShaderProperty(alphaMaskTransiton, Styles.alphaMaskTransitonText, indentation); m_MaterialEditor.ShaderProperty(alphaMaskEdge, Styles.alphaMaskEdgeText, indentation); //エッジ m_MaterialEditor.ShaderProperty(alphaMaskInverse, Styles.alphaMaskInverseText, indentation); //Alpha反転 m_MaterialEditor.ShaderProperty(imageIntensity, Styles.imageIntensityText, indentation); //Alpha反転 m_MaterialEditor.ShaderProperty(mainSpeedU, Styles.mainSpeedUText, indentation); m_MaterialEditor.ShaderProperty(mainSpeedV, Styles.mainSpeedVText, indentation); m_MaterialEditor.ShaderProperty(scale, Styles.scaleText, indentation); m_MaterialEditor.ShaderProperty(pixelSnap, Styles.pixelSnapText, indentation); //AlphaClip m_MaterialEditor.ShaderProperty(useUIAlphaClip, Styles.useUIAlphaClipText, indentation); m_MaterialEditor.ShaderProperty(cutoff, Styles.cutoffText, indentation); m_MaterialEditor.ShaderProperty(clipInverse, Styles.clipInverseText, indentation); m_MaterialEditor.ShaderProperty(alphaToMask, Styles.alphaToMaskText, indentation); //CullOff m_MaterialEditor.ShaderProperty(cullMode, Styles.cullModeText, indentation); //ColorMask m_MaterialEditor.ShaderProperty(colorMask, Styles.colorMaskText, indentation); //Stencil m_MaterialEditor.ShaderProperty(stencilComp, Styles.stencilCompText, indentation); m_MaterialEditor.ShaderProperty(stencilRef, Styles.stencilRefText, indentation); m_MaterialEditor.ShaderProperty(stencilPass, Styles.stencilPassText, indentation); //depth m_MaterialEditor.ShaderProperty(zWriteParam, Styles.zWriteParamText, indentation); m_MaterialEditor.ShaderProperty(zTestMode, Styles.zTestModeText, indentation); }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; // Detect any changes to the material EditorGUI.BeginChangeCheck(); { BlendModePopup(); // Primary properties GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel); DoAlbedoArea(material); DoSpecularMetallicArea(); m_MaterialEditor.ShaderProperty(startTime, "Start Time"); m_MaterialEditor.ShaderProperty(disSpeed, "Dissolve Speed"); m_MaterialEditor.ShaderProperty(duration, "Duration"); m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, bumpMap, bumpMap.textureValue != null ? bumpScale : null); m_MaterialEditor.TexturePropertySingleLine(Styles.heightMapText, heightMap, heightMap.textureValue != null ? heigtMapScale : null); m_MaterialEditor.TexturePropertySingleLine(Styles.occlusionText, occlusionMap, occlusionMap.textureValue != null ? occlusionStrength : null); DoEmissionArea(material); m_MaterialEditor.TexturePropertySingleLine(Styles.detailMaskText, detailMask); EditorGUI.BeginChangeCheck(); m_MaterialEditor.TextureScaleOffsetProperty(albedoMap); if (EditorGUI.EndChangeCheck()) { emissionMap.textureScaleAndOffset = albedoMap.textureScaleAndOffset; // Apply the main texture scale and offset to the emission texture as well, for Enlighten's sake } EditorGUILayout.Space(); // Secondary properties GUILayout.Label(Styles.secondaryMapsText, EditorStyles.boldLabel); m_MaterialEditor.TexturePropertySingleLine(Styles.detailAlbedoText, detailAlbedoMap); m_MaterialEditor.TexturePropertySingleLine(Styles.detailNormalMapText, detailNormalMap, detailNormalMapScale); m_MaterialEditor.TextureScaleOffsetProperty(detailAlbedoMap); m_MaterialEditor.ShaderProperty(uvSetSecondary, Styles.uvSetLabel.text); // Third properties GUILayout.Label(Styles.forwardText, EditorStyles.boldLabel); if (highlights != null) { m_MaterialEditor.ShaderProperty(highlights, Styles.highlightsText); } if (reflections != null) { m_MaterialEditor.ShaderProperty(reflections, Styles.reflectionsText); } EditorGUILayout.Space(); m_MaterialEditor.ShaderProperty(vertexColor, "Vertex Color"); } if (EditorGUI.EndChangeCheck()) { foreach (var obj in blendMode.targets) { MaterialChanged((Material)obj, m_WorkflowMode); } } }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; // Detect any changes to the material EditorGUI.BeginChangeCheck(); { BlendModePopup(); // Primary properties GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel); DoAlbedoArea(material); DoSpecularMetallicArea(material); if (brightness != null) { m_MaterialEditor.ShaderProperty(brightness, Styles.brightnessText, 0); } m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, bumpMap, bumpMap.textureValue != null ? bumpScale : null); m_MaterialEditor.TexturePropertySingleLine(Styles.heightMapText, heightMap, heightMap.textureValue != null ? heigtMapScale : null); m_MaterialEditor.TexturePropertySingleLine(Styles.occlusionText, occlusionMap, occlusionMap.textureValue != null ? occlusionStrength : null); DoEmissionArea(material); m_MaterialEditor.TexturePropertySingleLine(Styles.detailMaskText, detailMask); EditorGUI.BeginChangeCheck(); m_MaterialEditor.TextureScaleOffsetProperty(albedoMap); if (EditorGUI.EndChangeCheck()) { emissionMap.textureScaleAndOffset = albedoMap.textureScaleAndOffset; // Apply the main texture scale and offset to the emission texture as well, for Enlighten's sake } EditorGUILayout.Space(); // Secondary properties GUILayout.Label(Styles.secondaryMapsText, EditorStyles.boldLabel); m_MaterialEditor.TexturePropertySingleLine(Styles.detailAlbedoText, detailAlbedoMap); m_MaterialEditor.TexturePropertySingleLine(Styles.detailNormalMapText, detailNormalMap, detailNormalMapScale); m_MaterialEditor.TextureScaleOffsetProperty(detailAlbedoMap); m_MaterialEditor.ShaderProperty(uvSetSecondary, Styles.uvSetLabel.text); // Third properties GUILayout.Label(Styles.babylonText, EditorStyles.boldLabel); if (wireframe != null) { m_MaterialEditor.ShaderProperty(wireframe, Styles.wireframeText); } if (cameraContrast != null) { m_MaterialEditor.ShaderProperty(cameraContrast, Styles.cameraContrastText); } if (cameraExposure != null) { m_MaterialEditor.ShaderProperty(cameraExposure, Styles.cameraExposureText); } if (directIntensity != null) { m_MaterialEditor.ShaderProperty(directIntensity, Styles.directIntensityText); } if (emissiveIntensity != null) { m_MaterialEditor.ShaderProperty(emissiveIntensity, Styles.emissiveIntensityText); } if (specularIntensity != null) { m_MaterialEditor.ShaderProperty(specularIntensity, Styles.specularIntensityText); } if (backFaceCulling != null) { m_MaterialEditor.ShaderProperty(backFaceCulling, Styles.backFaceCullingText); } if (twoSidedLighting != null) { m_MaterialEditor.ShaderProperty(twoSidedLighting, Styles.twoSidedLightingText); } if (alphaMode != null) { m_MaterialEditor.ShaderProperty(alphaMode, Styles.alphaModeText); } if (refractionTexture != null) { m_MaterialEditor.ShaderProperty(refractionTexture, Styles.refractionTextureText); } if (indexOfRefraction != null) { m_MaterialEditor.ShaderProperty(indexOfRefraction, Styles.indexOfRefractionText); } if (linkRefractionWithTransparency != null) { m_MaterialEditor.ShaderProperty(linkRefractionWithTransparency, Styles.linkRefractionWithTransparencyText); } if (disableLighting != null) { m_MaterialEditor.ShaderProperty(disableLighting, Styles.disableLightingText); } if (maxSimultaneousLights != null) { m_MaterialEditor.ShaderProperty(maxSimultaneousLights, Styles.maxSimultaneousLightsText); } if (useEmissiveAsIllumination != null) { m_MaterialEditor.ShaderProperty(useEmissiveAsIllumination, Styles.useEmissiveAsIlluminationText); } if (useSpecularOverAlpha != null) { m_MaterialEditor.ShaderProperty(useSpecularOverAlpha, Styles.useSpecularOverAlphaText); } if (useRadianceOverAlpha != null) { m_MaterialEditor.ShaderProperty(useRadianceOverAlpha, Styles.useRadianceOverAlphaText); } if (usePhysicalLightFalloff != null) { m_MaterialEditor.ShaderProperty(usePhysicalLightFalloff, Styles.usePhysicalLightFalloffText); } // Forth properties GUILayout.Label(Styles.forwardText, EditorStyles.boldLabel); if (highlights != null) { m_MaterialEditor.ShaderProperty(highlights, Styles.highlightsText); } if (reflections != null) { m_MaterialEditor.ShaderProperty(reflections, Styles.reflectionsText); } if (reflectionScale != null) { m_MaterialEditor.ShaderProperty(reflectionScale, Styles.reflectionScaleText); } if (lightmapScale != null) { m_MaterialEditor.ShaderProperty(lightmapScale, Styles.lightmapScaleText); } if (environmentScale != null) { m_MaterialEditor.ShaderProperty(environmentScale, Styles.environmentScaleText); } } if (EditorGUI.EndChangeCheck()) { foreach (var obj in blendMode.targets) { MaterialChanged((Material)obj, m_WorkflowMode); } } }
public void ShaderPropertiesGUI(Material material) { EditorGUI.BeginChangeCheck(); { EditorGUIUtility.fieldWidth = 64f; EditorGUILayout.Separator(); InspectorBox(10, () => { EditorGUILayout.LabelField(new GUIContent("Surface"), EditorStyles.boldLabel); GUILayout.Space(5); matEditor.TexturePropertySingleLine(new GUIContent("Albedo"), mainTex); GUILayout.Space(5); matEditor.ShaderProperty(metallic, "Metallic"); matEditor.ShaderProperty(smoothness, "Smoothness"); }); EditorGUILayout.Separator(); InspectorBox(10, () => { //EditorGUILayout.LabelField(new GUIContent("Main Bending"), EditorStyles.boldLabel); //GUILayout.Space(5); matEditor.ShaderProperty(mbDefaultBending, new GUIContent("Default Bending", "The base bending applied to the model.")); GUILayout.Space(5); matEditor.ShaderProperty(mbAmplitude, new GUIContent("Amplitude", "The amplitude of the main bending.")); matEditor.ShaderProperty(mbAmplitudeOffset, new GUIContent("Amplitude Offset", "The amplitude offset of the main bending. The value of this field is multiplied with a static noise value and added to the main bending amplitude.")); GUILayout.Space(5); matEditor.ShaderProperty(mbFrequency, new GUIContent("Frequency", "The frequency of the main bending.")); matEditor.ShaderProperty(mbFrequencyOffset, new GUIContent("Frequency Offset", "The frequency offset of the main bending. The value of this field is multiplied with a static noise value and added to the main bending frequency.")); GUILayout.Space(5); matEditor.ShaderProperty(mbPhase, new GUIContent("Phase", "The phase of the main bending. A phase shift is applied based on the position the game object has on the XZ axis. " + "If the main bending of the models that are close to each other is synchronous, try to increase the value of this field.")); GUILayout.Space(5); matEditor.ShaderProperty(mbWindDirection, new GUIContent("Wind Dir", "The direction of the wind.")); matEditor.ShaderProperty(mbWindDirectionOffset, new GUIContent("Wind Dir Offset", "The wind direction offset. " + "This value is multiplied with an animated noise value and added to the wind direction to create wind direction variation over time.")); GUILayout.Space(5); matEditor.ShaderProperty(mbMaxHeight, new GUIContent("Max Height", "The height of the tallest model that uses this material. " + "This value is used to calculate the final main bending amplitude of a vertex.")); }); EditorGUILayout.Separator(); InspectorBox(10, () => { EditorGUILayout.LabelField(new GUIContent("World Space Noise"), EditorStyles.boldLabel); GUILayout.Space(5); matEditor.TexturePropertySingleLine(new GUIContent("Noise Texture"), noiseTexture); matEditor.ShaderProperty(noiseTextureTiling, new GUIContent("Noise Tiling: Static (XY), Animated (ZW)", "Noise texture tiling. " + "The XY values are used for static noise tiling and ZW for animated noise tiling.")); matEditor.ShaderProperty(noisePannerSpeed, new GUIContent("Noise Panning Speed", "The panning speed of the noise texture.")); }); EditorGUILayout.Separator(); InspectorBox(10, () => { GUILayout.Label("Advanced Options", EditorStyles.boldLabel); matEditor.EnableInstancingField(); }); } }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; // Detect any changes to the material EditorGUI.BeginChangeCheck(); { TriplanarSpacePopup(); m_MaterialEditor.RangeProperty(texturePower, "Texture Power"); m_MaterialEditor.RangeProperty(topMultiplier, "Top Multiplier"); m_MaterialEditor.RangeProperty(bottomMultiplier, "Bottom Multiplier"); if (vertexColorStrength != null) { m_MaterialEditor.RangeProperty(vertexColorStrength, Styles.vertexColorStrengthText.text); } DoAlbedoArea(material); DoSpecularMetallicArea(material); // bump GUILayout.Label(Styles.normalLabel, EditorStyles.boldLabel); m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, bumpMap, bumpMap.textureValue != null ? bumpScale : null); if (topMultiplier.floatValue > MIN_VALUE) { m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapTextTop, bumpMapTop, bumpMapTop.textureValue != null ? bumpScaleTop : null); } if (bottomMultiplier.floatValue > MIN_VALUE) { m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapTextBottom, bumpMapBottom, bumpMapBottom.textureValue != null ? bumpScaleBottom : null); } DoEmissionArea(material); // MAIN EditorGUILayout.Space(); GUILayout.Label(Styles.textureScaleOffset, EditorStyles.boldLabel); m_MaterialEditor.TextureScaleOffsetProperty(albedoMap); // TOP if (topMultiplier.floatValue > MIN_VALUE) { EditorGUILayout.Space(); GUILayout.Label(Styles.textureScaleOffsetTop, EditorStyles.boldLabel); m_MaterialEditor.TextureScaleOffsetProperty(albedoMapTop); } // BOTTOM if (bottomMultiplier.floatValue > MIN_VALUE) { EditorGUILayout.Space(); GUILayout.Label(Styles.textureScaleOffsetBottom, EditorStyles.boldLabel); m_MaterialEditor.TextureScaleOffsetProperty(albedoMapBottom); } } if (EditorGUI.EndChangeCheck()) { MaterialChanged(material, m_WorkflowMode); } }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; bool blendModeChanged = false; { blendModeChanged = BlendModePopup(); // Primary properties GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel); DoAlbedoArea(material); DoSpecularMetallicArea(); DoNormalArea(); m_MaterialEditor.TexturePropertySingleLine(Styles.heightMapText, heightMap, heightMap.textureValue != null ? heigtMapScale : null); m_MaterialEditor.TexturePropertySingleLine(Styles.occlusionText, occlusionMap, occlusionMap.textureValue != null ? occlusionStrength : null); m_MaterialEditor.TexturePropertySingleLine(Styles.detailMaskText, detailMask); DoEmissionArea(material); EditorGUI.BeginChangeCheck(); m_MaterialEditor.TextureScaleOffsetProperty(albedoMap); if (EditorGUI.EndChangeCheck()) { emissionMap.textureScaleAndOffset = albedoMap.textureScaleAndOffset; // Apply the main texture scale and offset to the emission texture as well, for Enlighten's sake } EditorGUILayout.Space(); // Secondary properties GUILayout.Label(Styles.secondaryMapsText, EditorStyles.boldLabel); m_MaterialEditor.TexturePropertySingleLine(Styles.detailAlbedoText, detailAlbedoMap); m_MaterialEditor.TexturePropertySingleLine(Styles.detailNormalMapText, detailNormalMap, detailNormalMapScale); m_MaterialEditor.TextureScaleOffsetProperty(detailAlbedoMap); m_MaterialEditor.ShaderProperty(uvSetSecondary, Styles.uvSetLabel.text); // Third properties GUILayout.Label(Styles.forwardText, EditorStyles.boldLabel); if (highlights != null) { m_MaterialEditor.ShaderProperty(highlights, Styles.highlightsText); } if (reflections != null) { m_MaterialEditor.ShaderProperty(reflections, Styles.reflectionsText); } EditorGUILayout.Space(); GUILayout.Label(Styles.advancedText, EditorStyles.boldLabel); m_MaterialEditor.RenderQueueField(); } if (blendModeChanged) { foreach (var obj in blendMode.targets) { SetupMaterialWithBlendMode((Material)obj, (BlendMode)((Material)obj).GetFloat("_Mode"), true); } } m_MaterialEditor.EnableInstancingField(); m_MaterialEditor.DoubleSidedGIField(); }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; // Detect any changes to the material EditorGUI.BeginChangeCheck(); { BlendModePopup(); // Primary properties GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel); DoAlbedoArea(material); DoSpecularMetallicArea(); m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, bumpMap, bumpMap.textureValue != null ? bumpScale : null); m_MaterialEditor.TexturePropertySingleLine(Styles.heightMapText, heightMap, heightMap.textureValue != null ? heigtMapScale : null); m_MaterialEditor.TexturePropertySingleLine(Styles.occlusionText, occlusionMap, occlusionMap.textureValue != null ? occlusionStrength : null); DoEmissionArea(material); m_MaterialEditor.TexturePropertySingleLine(Styles.detailMaskText, detailMask); EditorGUI.BeginChangeCheck(); m_MaterialEditor.TextureScaleOffsetProperty(albedoMap); if (EditorGUI.EndChangeCheck()) { emissionMap.textureScaleAndOffset = albedoMap.textureScaleAndOffset; // Apply the main texture scale and offset to the emission texture as well, for Enlighten's sake } EditorGUILayout.Space(); // Secondary properties GUILayout.Label(Styles.secondaryMapsText, EditorStyles.boldLabel); m_MaterialEditor.TexturePropertySingleLine(Styles.detailAlbedoText, detailAlbedoMap); m_MaterialEditor.TexturePropertySingleLine(Styles.detailNormalMapText, detailNormalMap, detailNormalMapScale); m_MaterialEditor.TextureScaleOffsetProperty(detailAlbedoMap); m_MaterialEditor.ShaderProperty(uvSetSecondary, Styles.uvSetLabel.text); // Third properties GUILayout.Label(Styles.forwardText, EditorStyles.boldLabel); if (highlights != null) { m_MaterialEditor.ShaderProperty(highlights, Styles.highlightsText); } if (reflections != null) { m_MaterialEditor.ShaderProperty(reflections, Styles.reflectionsText); } GUILayout.Label(Styles.bakeryText, EditorStyles.boldLabel); m_MaterialEditor.ShaderProperty(enableDoubleSidedOn, Styles.doubleSidedLabel); enableDoubleSided.floatValue = enableDoubleSidedOn.floatValue > 0 ? 0 : 2; m_MaterialEditor.ShaderProperty(enableVertexLM, Styles.vertexLMLabel); if (enableVertexLM.floatValue > 0) { m_MaterialEditor.ShaderProperty(enableVertexLMdir, Styles.vertexLMdirLabel); //if (enableVertexLMdir.floatValue > 0) enableVertexLMSH.floatValue = 0; } if (enableVertexLM.floatValue > 0) { m_MaterialEditor.ShaderProperty(enableVertexLMSH, Styles.vertexLMSHLabel); //if (enableVertexLMSH.floatValue > 0) enableVertexLMdir.floatValue = 0; } if (enableVertexLM.floatValue > 0) { m_MaterialEditor.ShaderProperty(enableVertexLMmask, Styles.vertexLMMaskLabel); } m_MaterialEditor.ShaderProperty(enableRNM, Styles.rnmLabel); m_MaterialEditor.ShaderProperty(enableSH, Styles.shLabel); if (enableSH.floatValue > 0 || enableVertexLMSH.floatValue > 0) { m_MaterialEditor.ShaderProperty(enableSHN, Styles.shnLabel); } m_MaterialEditor.ShaderProperty(enableSpec, Styles.specLabel); m_MaterialEditor.ShaderProperty(enableBicubic, Styles.bicubicLabel); m_MaterialEditor.ShaderProperty(enablePSHN, Styles.pshnLabel); m_MaterialEditor.ShaderProperty(enableVolumes, Styles.volLabel); if (enableVolumes.floatValue > 0) { var prevAssignedVolume = assignedVolume; assignedVolume = EditorGUILayout.ObjectField(volume0.textureValue == null ? "Assign volume" : "Assign different volume", assignedVolume, typeof(BakeryVolume), true) as BakeryVolume; if (prevAssignedVolume != assignedVolume) { volume0.textureValue = assignedVolume.bakedTexture0; volume1.textureValue = assignedVolume.bakedTexture1; volume2.textureValue = assignedVolume.bakedTexture2; volumeMask.textureValue = assignedVolume.bakedMask; var b = assignedVolume.bounds; volumeMin.vectorValue = b.min; volumeInvSize.vectorValue = new Vector3(1.0f / b.size.x, 1.0f / b.size.y, 1.0f / b.size.z); assignedVolume = null; } if (volume0.textureValue != null) { if (GUILayout.Button("Unset volume")) { volume0.textureValue = null; volume1.textureValue = null; volume2.textureValue = null; volumeMask.textureValue = null; volumeMin.vectorValue = Vector3.zero; volumeInvSize.vectorValue = Vector3.one * 1000001; } } EditorGUILayout.LabelField("Current Volume: " + (volume0.textureValue == null ? "<none or global>" : volume0.textureValue.name.Substring(0, volume0.textureValue.name.Length - 1))); EditorGUI.BeginDisabledGroup(true); m_MaterialEditor.TexturePropertySingleLine(Styles.volLabel0, volume0); m_MaterialEditor.TexturePropertySingleLine(Styles.volLabel1, volume1); m_MaterialEditor.TexturePropertySingleLine(Styles.volLabel2, volume2); m_MaterialEditor.TexturePropertySingleLine(Styles.volLabelMask, volumeMask); var bmin4 = volumeMin.vectorValue; var bmin = new Vector3(bmin4.x, bmin4.y, bmin4.z); var invSize = volumeInvSize.vectorValue; var bmax = new Vector3(1.0f / invSize.x + bmin.x, 1.0f / invSize.y + bmin.y, 1.0f / invSize.z + bmin.z); EditorGUILayout.LabelField("Min: " + bmin); EditorGUILayout.LabelField("Max: " + bmax); EditorGUI.EndDisabledGroup(); } EditorGUILayout.Space(); } if (EditorGUI.EndChangeCheck()) { foreach (var obj in blendMode.targets) { MaterialChanged((Material)obj, m_WorkflowMode); } } }
public virtual void DoDissolveArea(Material material) { m_MaterialEditor.TexturePropertySingleLine(Styles.dissolveMapText, dissolveMap); ShowDissolveMap(material); m_MaterialEditor.TexturePropertySingleLine(Styles.directionMapText, directionMap); if (substituteMap != null) { m_MaterialEditor.TexturePropertySingleLine(Styles.substituteText, substituteMap); } if (substituteColor != null) { m_MaterialEditor.ColorProperty(substituteColor, Styles.substituteColorText.text); } m_MaterialEditor.ShaderProperty(dissolveGlow, Styles.burnInText.text); if (material.IsKeywordEnabled("_DISSOLVEGLOW_ON")) { if (glowFollow != null) { m_MaterialEditor.ShaderProperty(glowFollow, Styles.glowFollowText.text); } m_MaterialEditor.ColorProperty(glowColor, Styles.burnColorText.text); m_MaterialEditor.FloatProperty(glowIntensity, Styles.burnIntensity.text); } if (!material.IsKeywordEnabled("_EDGECOLORRAMP_USE")) { m_MaterialEditor.ShaderProperty(colorBlend, Styles.blendColorsText.text); m_MaterialEditor.ColorProperty(outerEdgeColor, Styles.outerEdgeText.text); if (!material.IsKeywordEnabled("_COLORBLENDING_ON")) { m_MaterialEditor.ShaderProperty(outerEdgeThickness, Styles.edgeThicknessText.text, MaterialEditor.kMiniTextureFieldLabelIndentLevel + 1); } m_MaterialEditor.ColorProperty(innerEdgeColor, Styles.innerEdgeText.text); if (!material.IsKeywordEnabled("_COLORBLENDING_ON")) { m_MaterialEditor.ShaderProperty(innerEdgeThickness, Styles.edgeThicknessText.text, MaterialEditor.kMiniTextureFieldLabelIndentLevel + 1); } else { m_MaterialEditor.ShaderProperty(innerEdgeThickness, Styles.edgeThicknessSoloText.text); } } else { m_MaterialEditor.TexturePropertySingleLine(Styles.edgeColorRampText, edgeColorRamp); m_MaterialEditor.ShaderProperty(innerEdgeThickness, Styles.edgeThicknessSoloText.text); } EditorGUILayout.Space(); EditorGUI.indentLevel++; m_AdvancedSettings = EditorGUILayout.Foldout(m_AdvancedSettings, Styles.advancedSettings); if (m_AdvancedSettings) { EditorGUI.indentLevel++; EditorGUILayout.Space(); DoAdvancedArea(material); EditorGUI.indentLevel--; } EditorGUI.indentLevel--; }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; // Detect any changes to the material EditorGUI.BeginChangeCheck(); { BlendModePopup(); } if (EditorGUI.EndChangeCheck()) { foreach (var obj in blendMode.targets) { MaterialChanged((Material)obj); } } EditorGUI.BeginChangeCheck(); { EditorGUILayout.Space(); if ((BlendMode)material.GetFloat("_Mode") == BlendMode.Opaque || (BlendMode)material.GetFloat("_Mode") == BlendMode.Cutout) { m_MaterialEditor.ShaderProperty(player, Styles.playerText.text); } TwoSidedPopup(material); if ((BlendMode)material.GetFloat("_Mode") == BlendMode.Opaque || (BlendMode)material.GetFloat("_Mode") == BlendMode.Cutout) { m_MaterialEditor.ShaderProperty(vertexColorEnable, Styles.vertexColorEnableText.text); if (vertexColorEnable.floatValue == 1) { m_MaterialEditor.ShaderProperty(vertexColor, Styles.vertexColorText.text, MaterialEditor.kMiniTextureFieldLabelIndentLevel); } } if ((BlendMode)material.GetFloat("_Mode") == BlendMode.Fade || (BlendMode)material.GetFloat("_Mode") == BlendMode.Transparent) { m_MaterialEditor.ShaderProperty(vertexAlpha, Styles.vertexAlphaText.text); if (vertexAlpha.floatValue == 1) { m_MaterialEditor.ShaderProperty(vertexAlphaValue, Styles.vertexAlphaValueText.text, MaterialEditor.kMiniTextureFieldLabelIndentLevel); } m_MaterialEditor.ShaderProperty(extendAlpha, Styles.extendAlphaText.text); ZWritePopup(material); } m_MaterialEditor.ShaderProperty(receiveFog, Styles.receiveFogText.text); DoVertexAnimation(); DoRimArea(material); EditorGUILayout.Space(); EditorGUILayout.Space(); // Primary properties GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel); DoAlbedoArea(material); m_MaterialEditor.TextureScaleOffsetProperty(albedoMap); m_MaterialEditor.ShaderProperty(uvAnimation, Styles.uvAnimationText.text); EditorGUILayout.Space(); DoSpecularMetallicArea(); EditorGUILayout.Space(); DoNormalArea(); EditorGUILayout.Space(); m_MaterialEditor.TexturePropertySingleLine(Styles.heightMapText, heightMap, heightMap.textureValue != null ? heigtMapScale : null); EditorGUILayout.Space(); m_MaterialEditor.TexturePropertySingleLine(Styles.occlusionText, occlusionMap, occlusionMap.textureValue != null ? occlusionStrength : null); EditorGUILayout.Space(); DoEmissionArea(material); EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); if (EditorGUI.EndChangeCheck()) { emissionMap.textureScaleAndOffset = albedoMap.textureScaleAndOffset; // Apply the main texture scale and offset to the emission texture as well, for Enlighten's sake } EditorGUILayout.Space(); // Secondary properties GUILayout.Label(Styles.secondaryMapsText, EditorStyles.boldLabel); m_MaterialEditor.ShaderProperty(detailBlendMode, Styles.detailBlendModeText.text); m_MaterialEditor.TexturePropertySingleLine(Styles.detailMaskText, detailMask); m_MaterialEditor.TextureScaleOffsetProperty(detailMask); EditorGUILayout.Space(); m_MaterialEditor.TexturePropertySingleLine(Styles.detailAlbedoText, detailAlbedoMap); m_MaterialEditor.TextureScaleOffsetProperty(detailAlbedoMap); EditorGUILayout.Space(); m_MaterialEditor.TexturePropertySingleLine(Styles.detailNormalMapText, detailNormalMap, detailNormalMapScale); m_MaterialEditor.ShaderProperty(uvSetSecondary, Styles.uvSetLabel.text); m_MaterialEditor.RenderQueueField(); } if (EditorGUI.EndChangeCheck()) { foreach (var obj in blendMode.targets) { // MaterialChanged((Material)obj, m_WorkflowMode); SetMaterialKeywords((Material)obj); } } EditorGUILayout.Space(); // NB renderqueue editor is not shown on purpose: we want to override it based on blend mode GUILayout.Label(Styles.advancedText, EditorStyles.boldLabel); m_MaterialEditor.EnableInstancingField(); //m_MaterialEditor.DoubleSidedGIField(); }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; // Detect any changes to the material EditorGUI.BeginChangeCheck(); { m_MaterialEditor.ShaderProperty(unlit, Styles.unlitText.text); bool bUnlit = (unlit.floatValue != 0.0f); BlendModePopup(); if (!bUnlit) { SpecularModePopup(); } EditorGUILayout.Space(); //GUILayout.Label( Styles.primaryMapsText, EditorStyles.boldLabel ); DoAlbedoArea(material); if (!bUnlit) { m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, bumpMap, bumpMap.textureValue != null ? bumpScale : null); DoSpecularMetallicArea(material); m_MaterialEditor.TexturePropertySingleLine(Styles.occlusionText, occlusionMap, occlusionMap.textureValue != null ? occlusionStrength : null); if (occlusionMap.textureValue != null) { m_MaterialEditor.ShaderProperty(occlusionStrengthDirectDiffuse, Styles.occlusionStrengthDirectDiffuseText.text, 2); m_MaterialEditor.ShaderProperty(occlusionStrengthDirectSpecular, Styles.occlusionStrengthDirectSpecularText.text, 2); m_MaterialEditor.ShaderProperty(occlusionStrengthIndirectDiffuse, Styles.occlusionStrengthIndirectDiffuseText.text, 2); m_MaterialEditor.ShaderProperty(occlusionStrengthIndirectSpecular, Styles.occlusionStrengthIndirectSpecularText.text, 2); } m_MaterialEditor.ShaderProperty(cubeMapScalar, Styles.cubeMapScalarText.text, 0); } //m_MaterialEditor.TexturePropertySingleLine(Styles.heightMapText, heightMap, heightMap.textureValue != null ? heigtMapScale : null); DoEmissionArea(material); m_MaterialEditor.TexturePropertySingleLine(Styles.detailMaskText, detailMask); if (!bUnlit) { m_MaterialEditor.TexturePropertySingleLine(Styles.overrideLightmapText, overrideLightmap); } EditorGUI.BeginChangeCheck(); // !!! AV - This is from Unity's script. Can these Begin/End calls be nested like this? m_MaterialEditor.TextureScaleOffsetProperty(albedoMap); if (EditorGUI.EndChangeCheck()) { emissionMap.textureScaleAndOffset = albedoMap.textureScaleAndOffset; // Apply the main texture scale and offset to the emission texture as well, for Enlighten's sake } if (worldAlignedTexture != null) { m_MaterialEditor.ShaderProperty(worldAlignedTexture, Styles.worldAlignedTextureText.text); if (worldAlignedTexture.floatValue != 0.0f) { EditorGUI.indentLevel = 2; Vector3GUI(Styles.worldAlignedTextureSizeText, worldAlignedTextureSize); Vector3GUI(Styles.worldAlignedTextureNormalText, worldAlignedTextureNormal); Vector3GUI(Styles.worldAlignedTexturePositionText, worldAlignedTexturePosition); EditorGUI.indentLevel = 0; } } EditorGUILayout.Space(); // Secondary properties GUILayout.Label(Styles.secondaryMapsText, EditorStyles.boldLabel); m_MaterialEditor.TexturePropertySingleLine(Styles.detailAlbedoText, detailAlbedoMap); if (!bUnlit) { m_MaterialEditor.TexturePropertySingleLine(Styles.detailNormalMapText, detailNormalMap, detailNormalMapScale); } m_MaterialEditor.TextureScaleOffsetProperty(detailAlbedoMap); m_MaterialEditor.ShaderProperty(uvSetSecondary, Styles.uvSetLabel.text); } if (EditorGUI.EndChangeCheck()) { foreach (var obj in blendMode.targets) { MaterialChanged((Material)obj); } foreach (var obj in specularMode.targets) { MaterialChanged((Material)obj); } } }
void DoNormalArea(int index) { if (index == 0) { m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText0, bumpMap0, bumpMap0.textureValue != null ? bumpScale0 : null); if (bumpScale0.floatValue != 1 && UnityEditorInternal.InternalEditorUtility.IsMobilePlatform(EditorUserBuildSettings.activeBuildTarget)) { if (m_MaterialEditor.HelpBoxWithButton( EditorGUIUtility.TrTextContent("Bump scale is not supported on mobile platforms"), EditorGUIUtility.TrTextContent("Fix Now"))) { bumpScale0.floatValue = 1; } } } if (index == 1) { m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText1, bumpMap1, bumpMap1.textureValue != null ? bumpScale1 : null); if (bumpScale1.floatValue != 1 && UnityEditorInternal.InternalEditorUtility.IsMobilePlatform(EditorUserBuildSettings.activeBuildTarget)) { if (m_MaterialEditor.HelpBoxWithButton( EditorGUIUtility.TrTextContent("Bump scale is not supported on mobile platforms"), EditorGUIUtility.TrTextContent("Fix Now"))) { bumpScale1.floatValue = 1; } } } if (index == 2) { m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText2, bumpMap2, bumpMap2.textureValue != null ? bumpScale2 : null); if (bumpScale2.floatValue != 1 && UnityEditorInternal.InternalEditorUtility.IsMobilePlatform(EditorUserBuildSettings.activeBuildTarget)) { if (m_MaterialEditor.HelpBoxWithButton( EditorGUIUtility.TrTextContent("Bump scale is not supported on mobile platforms"), EditorGUIUtility.TrTextContent("Fix Now"))) { bumpScale2.floatValue = 1; } } } if (index == 3) { m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText3, bumpMap3, bumpMap3.textureValue != null ? bumpScale3 : null); if (bumpScale3.floatValue != 1 && UnityEditorInternal.InternalEditorUtility.IsMobilePlatform(EditorUserBuildSettings.activeBuildTarget)) { if (m_MaterialEditor.HelpBoxWithButton( EditorGUIUtility.TrTextContent("Bump scale is not supported on mobile platforms"), EditorGUIUtility.TrTextContent("Fix Now"))) { bumpScale3.floatValue = 1; } } } }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; // Detect any changes to the material EditorGUI.BeginChangeCheck(); { BlendModePopup(); //ProjectionModePopup(); if (EditorGUILayout.Toggle("Show Back Face", cullFace.floatValue > 0)) { cullFace.floatValue = 0.0f; switch ((BlendMode)material.GetFloat("_Mode")) { case BlendMode.Opaque: break; case BlendMode.Cutout: material.renderQueue = 2450; break; case BlendMode.Fade: material.renderQueue = 3000; break; case BlendMode.Transparent: material.renderQueue = 3000; break; } } else { cullFace.floatValue = 2.0f; switch ((BlendMode)material.GetFloat("_Mode")) { case BlendMode.Opaque: break; case BlendMode.Cutout: material.renderQueue = 2450; break; case BlendMode.Fade: material.renderQueue = 3000; break; case BlendMode.Transparent: material.renderQueue = 3000; break; } } // Primary properties GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel); DoAlbedoArea(material); DoSpecularMetallicArea(); m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, bumpMap, bumpMap.textureValue != null ? bumpScale : null); m_MaterialEditor.TexturePropertySingleLine(Styles.heightMapText, heightMap, heightMap.textureValue != null ? heigtMapScale : null); DoEmissionArea(material); m_MaterialEditor.TexturePropertySingleLine(Styles.detailMaskText, detailMask); EditorGUI.BeginChangeCheck(); m_MaterialEditor.TextureScaleOffsetProperty(albedoMap); if (EditorGUI.EndChangeCheck()) { emissionMap.textureScaleAndOffset = albedoMap.textureScaleAndOffset; // Apply the main texture scale and offset to the emission texture as well, for Enlighten's sake } EditorGUILayout.Space(); // Secondary properties GUILayout.Label(Styles.secondaryMapsText, EditorStyles.boldLabel); m_MaterialEditor.TexturePropertySingleLine(Styles.detailAlbedoText, detailAlbedoMap); m_MaterialEditor.TexturePropertySingleLine(Styles.detailNormalMapText, detailNormalMap, detailNormalMapScale); m_MaterialEditor.TextureScaleOffsetProperty(detailAlbedoMap); m_MaterialEditor.ShaderProperty(uvSetSecondary, Styles.uvSetLabel.text); } if (EditorGUI.EndChangeCheck()) { foreach (var obj in blendMode.targets) { MaterialChanged((Material)obj, m_WorkflowMode); } } }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; // Detect any changes to the material EditorGUI.BeginChangeCheck(); { // Blend mode BlendModePopup(); // Primary properties GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel); // Albedo _materialEditor.TexturePropertySingleLine(Styles.albedoText, _albedoMap); if (((BlendMode)material.GetFloat("_Mode") == BlendMode.Cutout)) { _materialEditor.ShaderProperty(_alphaCutoff, Styles.alphaCutoffText.text, MaterialEditor.kMiniTextureFieldLabelIndentLevel + 1); } // Normal _materialEditor.TexturePropertySingleLine(Styles.normalText, _normalMap); // Emission bool hadEmissionTexture = _emissionMap.textureValue != null; // Texture and HDR color controls _materialEditor.TexturePropertyWithHDRColor(Styles.emissionText, _emissionMap, _emissionColor, _ColorPickerHDRConfig, false); // If texture was assigned and color was black set color to white float brightness = _emissionColor.colorValue.maxColorComponent; if (_emissionMap.textureValue != null && !hadEmissionTexture && brightness <= 0f) { _emissionColor.colorValue = Color.white; } // Draw the tiliding and offset panels of the albedo map (which we'll use for the other textures too) EditorGUI.BeginChangeCheck(); _materialEditor.TextureScaleOffsetProperty(_albedoMap); if (EditorGUI.EndChangeCheck()) { _emissionMap.textureScaleAndOffset = _normalMap.textureScaleAndOffset = _albedoMap.textureScaleAndOffset; } // HSV GUILayout.Label(Styles.hsvText, EditorStyles.boldLabel); _materialEditor.ShaderProperty(_hue, Styles.hueText.text); _materialEditor.ShaderProperty(_saturation, Styles.saturationText.text); _materialEditor.ShaderProperty(_value, Styles.valueText.text); } if (EditorGUI.EndChangeCheck()) { // Set again the rendering tags and keywords foreach (var obj in _blendMode.targets) { Material mat = (Material)obj; switch ((BlendMode)mat.GetFloat("_Mode")) { case BlendMode.Opaque: mat.SetOverrideTag("RenderType", "Opaque"); mat.DisableKeyword("_ALPHATEST_ON"); mat.renderQueue = -1; break; case BlendMode.Cutout: mat.SetOverrideTag("RenderType", "TransparentCutout"); mat.EnableKeyword("_ALPHATEST_ON"); mat.renderQueue = (int)UnityEngine.Rendering.RenderQueue.AlphaTest; break; } } } }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; // Detect any changes to the material EditorGUI.BeginChangeCheck(); { BlendModePopup(); // Primary properties GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel); DoAlbedoArea(material); m_MaterialEditor.TexturePropertySingleLine(Styles.metallicMapText, metallicMap, metallicMap.textureValue != null ? null : metallic); m_MaterialEditor.TexturePropertySingleLine(Styles.roughnessText, roughnessMap, roughnessMap.textureValue != null ? null : roughness); m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, bumpMap, bumpMap.textureValue != null ? bumpScale : null); m_MaterialEditor.TexturePropertySingleLine(Styles.heightMapText, heightMap, heightMap.textureValue != null ? heigtMapScale : null); m_MaterialEditor.TexturePropertySingleLine(Styles.occlusionText, occlusionMap, occlusionMap.textureValue != null ? occlusionStrength : null); m_MaterialEditor.TexturePropertySingleLine(Styles.detailMaskText, detailMask); DoEmissionArea(material); EditorGUI.BeginChangeCheck(); m_MaterialEditor.TextureScaleOffsetProperty(albedoMap); if (EditorGUI.EndChangeCheck()) { emissionMap.textureScaleAndOffset = albedoMap.textureScaleAndOffset; // Apply the main texture scale and offset to the emission texture as well, for Enlighten's sake } EditorGUILayout.Space(); // Secondary properties GUILayout.Label(Styles.secondaryMapsText, EditorStyles.boldLabel); m_MaterialEditor.TexturePropertySingleLine(Styles.detailAlbedoText, detailAlbedoMap); m_MaterialEditor.TexturePropertySingleLine(Styles.detailNormalMapText, detailNormalMap, detailNormalMapScale); m_MaterialEditor.TextureScaleOffsetProperty(detailAlbedoMap); m_MaterialEditor.ShaderProperty(uvSetSecondary, Styles.uvSetLabel.text); // Third properties GUILayout.Label(Styles.forwardText, EditorStyles.boldLabel); if (highlights != null) { m_MaterialEditor.ShaderProperty(highlights, Styles.highlightsText); } if (reflections != null) { m_MaterialEditor.ShaderProperty(reflections, Styles.reflectionsText); } } if (EditorGUI.EndChangeCheck()) { foreach (var obj in blendMode.targets) { MaterialChanged((Material)obj); } } EditorGUILayout.Space(); // NB renderqueue editor is not shown on purpose: we want to override it based on blend mode GUILayout.Label(Styles.advancedText, EditorStyles.boldLabel); m_MaterialEditor.EnableInstancingField(); var ignoreGlobalFX = material.IsKeywordEnabled("_IGNORE_GLOBAL_FX"); using (var changeScope = new EditorGUI.ChangeCheckScope()) { ignoreGlobalFX = EditorGUILayout.Toggle("Ignore Global FX", ignoreGlobalFX); if (changeScope.changed) { if (ignoreGlobalFX) { material.EnableKeyword("_IGNORE_GLOBAL_FX"); } else { material.DisableKeyword("_IGNORE_GLOBAL_FX"); } } } }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; // Detect any changes to the material EditorGUI.BeginChangeCheck(); { BlendModePopup(); // Primary properties GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel); DoAlbedoArea(material); DoSpecularMetallicArea(); m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, bumpMap, bumpMap.textureValue != null ? bumpScale : null); m_MaterialEditor.TexturePropertySingleLine(Styles.heightMapText, heightMap, heightMap.textureValue != null ? heigtMapScale : null); m_MaterialEditor.TexturePropertySingleLine(Styles.occlusionText, occlusionMap, occlusionMap.textureValue != null ? occlusionStrength : null); DoEmissionArea(material); m_MaterialEditor.TexturePropertySingleLine(Styles.detailMaskText, detailMask); m_MaterialEditor.TextureScaleOffsetProperty(albedoMap); EditorGUILayout.Space(); // Secondary properties GUILayout.Label(Styles.secondaryMapsText, EditorStyles.boldLabel); m_MaterialEditor.TexturePropertySingleLine(Styles.detailAlbedoText, detailAlbedoMap); m_MaterialEditor.TexturePropertySingleLine(Styles.detailNormalMapText, detailNormalMap, detailNormalMapScale); m_MaterialEditor.TextureScaleOffsetProperty(detailAlbedoMap); m_MaterialEditor.ShaderProperty(uvSetSecondary, Styles.uvSetLabel.text); m_MaterialEditor.ShaderProperty(nearCurve, Styles.nearCurveLabel.text); m_MaterialEditor.ShaderProperty(farCurve, Styles.farCurveLabel.text); m_MaterialEditor.ShaderProperty(dist, Styles.distLabel.text); } if (EditorGUI.EndChangeCheck()) { foreach (var obj in blendMode.targets) { MaterialChanged((Material)obj, m_WorkflowMode); } } }
bool ShaderPropertiesGUI(MaterialEditor materialEditor) { EditorGUI.BeginChangeCheck(); EditorGUILayout.LabelField("Front-face properties", EditorStyles.boldLabel); EditorGUILayout.Space(); // albedo materialEditor.TexturePropertySingleLine(_albedoText, _mainTex, _color); // metallic / smoothness if (_metallicGlossMap.textureValue == null) materialEditor.TexturePropertyTwoLines(_metallicText, _metallicGlossMap, _metallic, _smoothnessText, _glossiness); else materialEditor.TexturePropertySingleLine(_metallicText, _metallicGlossMap); // normal map materialEditor.TexturePropertySingleLine(_normalMapText, _bumpMap, _bumpMap.textureValue != null ? _bumpScale : null); // occlusion materialEditor.TexturePropertySingleLine(_occlusionText, _occlusionMap, _occlusionMap.textureValue != null ? _occlusionStrength : null); // emission bool hadEmissionTexture = _emissionMap.textureValue != null; materialEditor.TexturePropertyWithHDRColor(_emissionText, _emissionMap, _emissionColor, _colorPickerHDRConfig, false); // if texture was assigned and color was black set color to white if (_emissionMap.textureValue != null && !hadEmissionTexture) if (_emissionColor.colorValue.maxColorComponent <= 0) _emissionColor.colorValue = Color.white; EditorGUILayout.Space(); // backface properties EditorGUILayout.LabelField("Back-face properties", EditorStyles.boldLabel); EditorGUILayout.Space(); materialEditor.ShaderProperty(_backColor, "Color"); materialEditor.ShaderProperty(_backMetallic, "Matallic"); materialEditor.ShaderProperty(_backGlossiness, "Smoothness"); return EditorGUI.EndChangeCheck(); }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; // Detect any changes to the material EditorGUI.BeginChangeCheck(); { BlendModePopup(); m_MaterialEditor.ShaderProperty(cullMode, Styles.cullText); if (outlineEnabled.floatValue == 0) { stencilRef.floatValue = 0; } GUILayout.BeginHorizontal(); ButtonToggle(ref stylizeRamp, "Custom Ramp"); ButtonToggle(ref stylizeSpec, "Custom Specular"); ButtonToggle(ref stylizeRim, "Custom Rim"); ButtonToggle(ref outlineEnabled, "Outlines"); GUILayout.EndHorizontal(); // Primary properties GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel); DoAlbedoArea(material); DoSpecularMetallicArea(); DoNormalArea(); m_MaterialEditor.TexturePropertySingleLine(Styles.heightMapText, heightMap, heightMap.textureValue != null ? heigtMapScale : null); if (advancedChannels.floatValue == 1) { ProperPopup(ref heightEnum, 100); } m_MaterialEditor.TexturePropertySingleLine(Styles.occlusionText, occlusionMap, occlusionMap.textureValue != null ? occlusionStrength : null); if (advancedChannels.floatValue == 1) { ProperPopup(ref occlusionEnum, 90); } m_MaterialEditor.TexturePropertySingleLine(Styles.detailMaskText, detailMask); if (advancedChannels.floatValue == 1) { ProperPopup(ref maskEnum, 102); } DoEmissionArea(material); EditorGUI.BeginChangeCheck(); m_MaterialEditor.TextureScaleOffsetProperty(albedoMap); if (EditorGUI.EndChangeCheck()) { emissionMap.textureScaleAndOffset = albedoMap.textureScaleAndOffset; // Apply the main texture scale and offset to the emission texture as well, for Enlighten's sake } EditorGUILayout.Space(); // Secondary properties GUILayout.Label(Styles.secondaryMapsText, EditorStyles.boldLabel); m_MaterialEditor.TexturePropertySingleLine(Styles.detailAlbedoText, detailAlbedoMap, detailColor); m_MaterialEditor.TexturePropertySingleLine(Styles.detailNormalMapText, detailNormalMap, detailNormalMapScale); m_MaterialEditor.TextureScaleOffsetProperty(detailAlbedoMap); m_MaterialEditor.ShaderProperty(uvSetSecondary, Styles.uvSetLabel.text); // Third properties GUILayout.Label(Styles.forwardText, EditorStyles.boldLabel); if (highlights != null) { m_MaterialEditor.ShaderProperty(highlights, Styles.highlightsText); } if (reflections != null) { m_MaterialEditor.ShaderProperty(reflections, Styles.reflectionsText); } } if (EditorGUI.EndChangeCheck()) { foreach (var obj in blendMode.targets) { MaterialChanged((Material)obj, m_WorkflowMode); } } EditorGUILayout.Space(); // NB renderqueue editor is not shown on purpose: we want to override it based on blend mode GUILayout.Label(Styles.advancedText, EditorStyles.boldLabel); m_MaterialEditor.ShaderProperty(advancedChannels, Styles.advancedChannelsText); m_MaterialEditor.EnableInstancingField(); m_MaterialEditor.DoubleSidedGIField(); }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; // Detect any changes to the material EditorGUI.BeginChangeCheck(); { BlendModePopup(); GUILayout.Label(Styles.tessellationText, EditorStyles.boldLabel); m_MaterialEditor.ShaderProperty(tessmode, Styles.tessModeText.text); CheckTessMode(); if (m_TessWorkflowMode == TessWorkflowMode.Distance) { m_MaterialEditor.ShaderProperty(tessellation, Styles.tessFacText.text); m_MaterialEditor.ShaderProperty(maxdist, Styles.tessMaxText.text); } else { m_MaterialEditor.ShaderProperty(tessellation, Styles.edgelenText.text); } m_MaterialEditor.ShaderProperty(shadowgen, Styles.shoadowGenText.text); EditorGUILayout.Space(); GUILayout.Label(Styles.displacementText, EditorStyles.boldLabel); m_MaterialEditor.ShaderProperty(phong, Styles.phongText.text); m_MaterialEditor.ShaderProperty(displacement, Styles.dispScaleText.text); m_MaterialEditor.ShaderProperty(dispoffset, Styles.dispOffsetText.text); EditorGUILayout.Space(); // Primary properties GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel); DoAlbedoArea(material); DoSpecularMetallicArea(); m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, bumpMap, bumpMap.textureValue != null ? bumpScale : null); m_MaterialEditor.TexturePropertySingleLine(Styles.heightMapText, heightMap); m_MaterialEditor.TexturePropertySingleLine(Styles.occlusionText, occlusionMap, occlusionMap.textureValue != null ? occlusionStrength : null); m_MaterialEditor.TexturePropertySingleLine(Styles.detailMaskText, detailMask); DoEmissionArea(material); EditorGUI.BeginChangeCheck(); m_MaterialEditor.TextureScaleOffsetProperty(albedoMap); if (EditorGUI.EndChangeCheck()) { emissionMap.textureScaleAndOffset = albedoMap.textureScaleAndOffset; // Apply the main texture scale and offset to the emission texture as well, for Enlighten's sake } EditorGUILayout.Space(); // Secondary properties GUILayout.Label(Styles.secondaryMapsText, EditorStyles.boldLabel); m_MaterialEditor.TexturePropertySingleLine(Styles.detailAlbedoText, detailAlbedoMap); m_MaterialEditor.TexturePropertySingleLine(Styles.detailNormalMapText, detailNormalMap, detailNormalMapScale); m_MaterialEditor.TextureScaleOffsetProperty(detailAlbedoMap); m_MaterialEditor.ShaderProperty(uvSetSecondary, Styles.uvSetLabel.text); // Third properties GUILayout.Label(Styles.forwardText, EditorStyles.boldLabel); if (highlights != null) { m_MaterialEditor.ShaderProperty(highlights, Styles.highlightsText); } if (reflections != null) { m_MaterialEditor.ShaderProperty(reflections, Styles.reflectionsText); } } if (EditorGUI.EndChangeCheck()) { foreach (var obj in blendMode.targets) { MaterialChanged((Material)obj, m_WorkflowMode, m_TessWorkflowMode); } } EditorGUILayout.Space(); GUILayout.Label(Styles.advancedText, EditorStyles.boldLabel); m_MaterialEditor.RenderQueueField(); m_MaterialEditor.EnableInstancingField(); }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; // Detect any changes to the material EditorGUI.BeginChangeCheck(); { BlendModePopup(material); EditorGUI.BeginChangeCheck(); m_OverrideRenderQueue = EditorGUILayout.Toggle("Override Render Queue", m_OverrideRenderQueue); if (EditorGUI.EndChangeCheck()) { if (!m_OverrideRenderQueue) { switch ((BlendMode)blendMode.floatValue) { case BlendMode.Opaque: material.renderQueue = -1; break; case BlendMode.Cutout: material.renderQueue = (int)UnityEngine.Rendering.RenderQueue.AlphaTest; break; case BlendMode.Fade: material.renderQueue = (int)UnityEngine.Rendering.RenderQueue.Transparent; break; case BlendMode.Transparent: material.renderQueue = (int)UnityEngine.Rendering.RenderQueue.Transparent; break; } } } if (m_OverrideRenderQueue) { m_MaterialEditor.RenderQueueField(); } // Primary properties GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel); DoAlbedoArea(material); m_MaterialEditor.TexturePropertySingleLine(Styles.metallicMapText, metallicMap, metallicMap.textureValue != null ? null : metallic); m_MaterialEditor.TexturePropertySingleLine(Styles.roughnessText, roughnessMap, roughnessMap.textureValue != null ? null : roughness); m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, bumpMap, bumpMap.textureValue != null ? bumpScale : null); m_MaterialEditor.TexturePropertySingleLine(Styles.heightMapText, heightMap, heightMap.textureValue != null ? heigtMapScale : null); m_MaterialEditor.TexturePropertySingleLine(Styles.occlusionText, occlusionMap, occlusionMap.textureValue != null ? occlusionStrength : null); m_MaterialEditor.TexturePropertySingleLine(Styles.detailMaskText, detailMask); DoEmissionArea(material); EditorGUI.BeginChangeCheck(); m_MaterialEditor.TextureScaleOffsetProperty(albedoMap); if (EditorGUI.EndChangeCheck()) { emissionMap.textureScaleAndOffset = albedoMap.textureScaleAndOffset; // Apply the main texture scale and offset to the emission texture as well, for Enlighten's sake } EditorGUILayout.Space(); // Secondary properties GUILayout.Label(Styles.secondaryMapsText, EditorStyles.boldLabel); m_MaterialEditor.TexturePropertySingleLine(Styles.detailAlbedoText, detailAlbedoMap); m_MaterialEditor.TexturePropertySingleLine(Styles.detailNormalMapText, detailNormalMap, detailNormalMapScale); m_MaterialEditor.TextureScaleOffsetProperty(detailAlbedoMap); m_MaterialEditor.ShaderProperty(uvSetSecondary, Styles.uvSetLabel.text); // Third properties GUILayout.Label(Styles.forwardText, EditorStyles.boldLabel); if (highlights != null) { m_MaterialEditor.ShaderProperty(highlights, Styles.highlightsText); } if (reflections != null) { m_MaterialEditor.ShaderProperty(reflections, Styles.reflectionsText); } } if (EditorGUI.EndChangeCheck()) { foreach (var obj in blendMode.targets) { MaterialChanged((Material)obj); } } EditorGUILayout.Space(); // NB renderqueue editor is not shown on purpose: we want to override it based on blend mode GUILayout.Label(Styles.advancedText, EditorStyles.boldLabel); m_MaterialEditor.EnableInstancingField(); m_MaterialEditor.DoubleSidedGIField(); }
void ImmediateProperty(string name, MaterialEditor materialEditor, MaterialProperty[] props) { var p = FindProperty(name, props); if (p.type == MaterialProperty.PropType.Texture) materialEditor.TexturePropertySingleLine(new GUIContent(p.displayName), p); else materialEditor.ShaderProperty(p, p.displayName); }
void ColorProperty() { editor.TexturePropertySingleLine(mainTexturePropertyText, mainTex, color); }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; // Detect any changes to the material EditorGUI.BeginChangeCheck(); { BlendModePopup(); // Main Maps GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel); DoAlbedoArea(material); DoSpecularMetallicArea(); m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, bumpMap, bumpMap.textureValue != null ? bumpScale : null); m_MaterialEditor.TexturePropertySingleLine(Styles.heightMapText, heightMap, heightMap.textureValue != null ? heigtMapScale : null); m_MaterialEditor.TexturePropertySingleLine(Styles.occlusionText, occlusionMap, occlusionMap.textureValue != null ? occlusionStrength : null); m_MaterialEditor.TexturePropertySingleLine(Styles.detailMaskText, detailMask); DoEmissionArea(material); EditorGUI.BeginChangeCheck(); m_MaterialEditor.TextureScaleOffsetProperty(albedoMap); if (EditorGUI.EndChangeCheck()) { emissionMap.textureScaleAndOffset = albedoMap.textureScaleAndOffset; // Apply the main texture scale and offset to the emission texture as well, for Enlighten's sake } EditorGUILayout.Space(); // Secondary Maps GUILayout.Label(Styles.secondaryMapsText, EditorStyles.boldLabel); m_MaterialEditor.TexturePropertySingleLine(Styles.detailAlbedoText, detailAlbedoMap); m_MaterialEditor.TexturePropertySingleLine(Styles.detailNormalMapText, detailNormalMap, detailNormalMapScale); m_MaterialEditor.TextureScaleOffsetProperty(detailAlbedoMap); m_MaterialEditor.ShaderProperty(uvSetSecondary, Styles.uvSetLabel.text); // Forward Rendering Options GUILayout.Label(Styles.forwardText, EditorStyles.boldLabel); if (highlights != null) { m_MaterialEditor.ShaderProperty(highlights, Styles.highlightsText); } if (reflections != null) { m_MaterialEditor.ShaderProperty(reflections, Styles.reflectionsText); } } if (EditorGUI.EndChangeCheck()) { foreach (var obj in blendMode.targets) { MaterialChanged((Material)obj, m_WorkflowMode); } } EditorGUILayout.Space(); // Advanced Options GUILayout.Label(Styles.advancedText, EditorStyles.boldLabel); m_MaterialEditor.RenderQueueField(); m_MaterialEditor.EnableInstancingField(); EditorGUILayout.Space(); // Scan Properties *** // GUILayout.Label(Styles.rimTitle, EditorStyles.boldLabel); // m_MaterialEditor.ShaderProperty(rimColor, Styles.rimColorText); // m_MaterialEditor.ShaderProperty(rimPower, Styles.rimPowerText); // ******************* }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; // Detect any changes to the material EditorGUI.BeginChangeCheck(); { BlendModePopup(); //MixModePopup(); // Primary properties GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel); DoAlbedoArea(material); DoSpecularMetallicArea(); DoNormalArea(); m_MaterialEditor.TexturePropertySingleLine(Styles.heightMapText, heightMap, heightMap.textureValue != null ? heigtMapScale : null); m_MaterialEditor.TexturePropertySingleLine(Styles.occlusionText, occlusionMap, occlusionMap.textureValue != null ? occlusionStrength : null); m_MaterialEditor.TexturePropertySingleLine(Styles.detailMaskText, detailMask); DoEmissionArea(material); EditorGUI.BeginChangeCheck(); m_MaterialEditor.TextureScaleOffsetProperty(albedoMap); if (EditorGUI.EndChangeCheck()) { emissionMap.textureScaleAndOffset = albedoMap.textureScaleAndOffset; // Apply the main texture scale and offset to the emission texture as well, for Enlighten's sake } EditorGUILayout.Space(); // Secondary properties GUILayout.Label(Styles.secondaryMapsText, EditorStyles.boldLabel); m_MaterialEditor.TexturePropertySingleLine(Styles.detailAlbedoText, detailAlbedoMap); //m_MaterialEditor.TexturePropertySingleLine(Styles.detailSpecText, detailSpecMap); m_MaterialEditor.TexturePropertySingleLine(Styles.detailNormalMapText, detailNormalMap, detailNormalMapScale); m_MaterialEditor.TextureScaleOffsetProperty(detailAlbedoMap); //m_MaterialEditor.TextureScaleOffsetProperty(detailSpecMap); DoSpecularMetallicDetailArea(); m_MaterialEditor.ShaderProperty(uvSetSecondary, Styles.uvSetLabel.text); //m_MaterialEditor.ShaderProperty(mixDetailColors, Styles.mixSetLabel.text); // Third properties GUILayout.Label(Styles.forwardText, EditorStyles.boldLabel); if (highlights != null) { m_MaterialEditor.ShaderProperty(highlights, Styles.highlightsText); } if (reflections != null) { m_MaterialEditor.ShaderProperty(reflections, Styles.reflectionsText); } } if (EditorGUI.EndChangeCheck()) { foreach (var obj in blendMode.targets) { MaterialChanged((Material)obj, m_WorkflowMode); } } EditorGUILayout.Space(); // NB renderqueue editor is not shown on purpose: we want to override it based on blend mode GUILayout.Label(Styles.advancedText, EditorStyles.boldLabel); m_MaterialEditor.EnableInstancingField(); m_MaterialEditor.DoubleSidedGIField(); }
bool ImmediateProperty(string name, MaterialEditor materialEditor, MaterialProperty[] props) { EditorGUI.BeginChangeCheck(); var p = FindProperty(name, props); if(p.type == MaterialProperty.PropType.Texture) materialEditor.TexturePropertySingleLine(new GUIContent(p.displayName), p); else materialEditor.ShaderProperty(p, p.displayName); return EditorGUI.EndChangeCheck(); }