//https://github.com/Unity-Technologies/ScriptableRenderPipeline/blob/648184ec8405115e2fcf4ad3023d8b16a191c4c7/com.unity.render-pipelines.universal/Editor/ShaderGUI/BaseShaderGUI.cs public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props) { this.materialEditor = materialEditor; materialEditor.SetDefaultGUIWidths(); materialEditor.UseDefaultMargins(); EditorGUIUtility.labelWidth = 0f; targetMat = materialEditor.target as Material; keyWords = targetMat.shaderKeywords; FindProperties(props); //base.OnGUI(materialEditor, props); //return; EditorGUILayout.LabelField(AssetInfo.ASSET_NAME + " " + AssetInfo.INSTALLED_VERSION, EditorStyles.centeredGreyMiniLabel); EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField("Lighting", GUILayout.Width(EditorGUIUtility.labelWidth)); advancedLighting.floatValue = (float)GUILayout.Toolbar((int)advancedLighting.floatValue, new GUIContent[] { simpleLightingContent, advancedLightingContent } ); } EditorGUILayout.Space(); DrawRendering(); EditorGUILayout.Space(); DrawMaps(); EditorGUILayout.Space(); DrawColor(); EditorGUILayout.Space(); DrawShading(); EditorGUILayout.Space(); DrawBending(); EditorGUILayout.Space(); DrawWind(); EditorGUILayout.Space(); materialEditor.EnableInstancingField(); if (!materialEditor.IsInstancingEnabled()) { EditorGUILayout.HelpBox("GPU Instancing is highly recommended for optimal performance", MessageType.Warning); } materialEditor.RenderQueueField(); materialEditor.DoubleSidedGIField(); if (EditorGUI.EndChangeCheck()) { ApplyChanges(); } EditorGUILayout.Space(); EditorGUILayout.LabelField("- Staggart Creations -", EditorStyles.centeredGreyMiniLabel); }
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(); 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); } } 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(); }
protected void DoMaterialRenderingOptions() { EditorGUILayout.Space(); GUILayout.Label(Styles.renderingOptionsLabel, 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(); { BaseMaterialPropertiesGUI(); EditorGUILayout.Space(); VertexAnimationPropertiesGUI(); EditorGUILayout.Space(); MaterialPropertiesGUI(material); DoEmissionArea(material); GUILayout.Label(StylesBaseUnlit.advancedText, EditorStyles.boldLabel); // NB renderqueue editor is not shown on purpose: we want to override it based on blend mode m_MaterialEditor.EnableInstancingField(); m_MaterialEditor.DoubleSidedGIField(); } if (EditorGUI.EndChangeCheck()) { foreach (var obj in m_MaterialEditor.targets) { SetupMaterialKeywordsAndPassInternal((Material)obj); } } }
private void DrawMaterialOptions(MaterialEditor editor, Material mat) { var advState = EditorGUILayout.BeginFoldoutHeaderGroup(GetToggleState("Advanced"), Styles.OptionsHeaderContent); if (advState) { { int vmMode = mat.GetInt("_ViewModel"); var t = EditorGUILayout.Toggle(Styles.ViewmodelModeContent, vmMode > 0); mat.SetInt("_ViewModel", t ? 1 : 0); } editor.EnableInstancingField(); if (emissiveTex.textureValue == null) { EditorGUILayout.HelpBox(Styles.EmissiveNoticeContent.text, MessageType.Warning); } EditorGUI.BeginDisabledGroup(emissiveTex.textureValue == null); { editor.LightmapEmissionProperty(); editor.DoubleSidedGIField(); } EditorGUI.EndDisabledGroup(); } SetToggleState("Advanced", advState); EditorGUILayout.EndFoldoutHeaderGroup(); }
public override void OnGUI(MaterialEditor editor, MaterialProperty[] aProp) { var _MainTex = FindProperty("_MainTex", aProp); editor.ShaderProperty(_MainTex, _MainTex.displayName); var _AlphaCutoutThreshold = FindProperty("_AlphaCutoutThreshold", aProp); editor.ShaderProperty(_AlphaCutoutThreshold, _AlphaCutoutThreshold.displayName); var _Dithering = FindProperty("_Dithering", aProp); editor.ShaderProperty(_Dithering, _Dithering.displayName); var _DitherTexture = FindProperty("_DitherTexture", aProp); editor.ShaderProperty(_DitherTexture, _DitherTexture.displayName); var _DitherTextureSize = FindProperty("_DitherTextureSize", aProp); editor.ShaderProperty(_DitherTextureSize, _DitherTextureSize.displayName); var _RandomDither = FindProperty("_RandomDither", aProp); editor.ShaderProperty(_RandomDither, _RandomDither.displayName); EditorGUILayout.Space(); editor.RenderQueueField(); editor.DoubleSidedGIField(); }
/// <summary> /// Shows Queue, instancing and doublesided GI /// </summary> /// <param name="me"></param> protected void ShowAdvancedOptions(MaterialEditor me) { GUILayout.Space(30); EditorGUILayout.LabelField("Advanced Options", EditorStyles.boldLabel); me.RenderQueueField(); me.EnableInstancingField(); me.DoubleSidedGIField(); }
protected static void AdvancedOptionsGUI(MaterialEditor materialEditor) { EditorGUILayout.Space(); EditorGUILayout.LabelField("Advanced Options", EditorStyles.boldLabel); materialEditor.RenderQueueField(); materialEditor.EnableInstancingField(); materialEditor.DoubleSidedGIField(); }
void DrawAdvancedOptions() { EditorGUILayout.Space(); GUILayout.Label("Advanced Options", EditorStyles.boldLabel); m_MaterialEditor.EnableInstancingField(); m_MaterialEditor.RenderQueueField(); m_MaterialEditor.DoubleSidedGIField(); }
protected override void DrawPipeline(MaterialEditor materialEditor) { DrawPipelineHeader(); materialEditor.EnableInstancingField(); materialEditor.DoubleSidedGIField(); DrawRenderPriority(materialEditor); }
public override void OnGUI(MaterialEditor editor, MaterialProperty[] properties) { foreach (var property in properties) { bool hideInInspector = (property.flags & MaterialProperty.PropFlags.HideInInspector) != 0; if (hideInInspector) { continue; } var tooltip = Tooltips.Get(editor, property.displayName); if (property.displayName.Contains("[Header]")) { DrawHeader(property, tooltip); continue; } if (property.displayName.Contains("[Space]")) { EditorGUILayout.Space(); continue; } var displayName = property.displayName; displayName = HandleTabs(displayName); displayName = RemoveEverythingInBrackets(displayName); if (property.type == MaterialProperty.PropType.Texture && property.name.Contains("GradientTexture")) { EditorGUILayout.Space(18); _gradientDrawer.OnGUI(Rect.zero, property, property.displayName, editor, tooltip); } else if (property.type == MaterialProperty.PropType.Vector && property.displayName.Contains("[Vector2]")) { EditorGUILayout.Space(18); _vectorDrawer.OnGUI(Rect.zero, property, displayName, editor, tooltip); } else { var guiContent = new GUIContent(displayName, tooltip); editor.ShaderProperty(property, guiContent); } } EditorGUILayout.Space(); EditorGUILayout.Space(); if (SupportedRenderingFeatures.active.editableMaterialRenderQueue) { editor.RenderQueueField(); } editor.EnableInstancingField(); editor.DoubleSidedGIField(); }
public void ShaderPropertiesGUI(Material material) { EditorGUIUtility.labelWidth = 0f; // Use default labelWidth EditorGUI.BeginChangeCheck(); { DoBlendModeArea(); // Primary properties GUILayout.Label(Styles.primaryPropertiesText, EditorStyles.boldLabel); DoAlbedoArea(material); DoSpecularArea(); DoSubsurfaceArea(); DoNormalArea(); DoOcclusionArea(); 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(); // Rendering properties GUILayout.Label(Styles.renderingOptionsText, EditorStyles.boldLabel); if (fresnel != null) { DoFresnelArea(); } 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(); GUILayout.Label(Styles.advancedText, EditorStyles.boldLabel); m_MaterialEditor.RenderQueueField(); m_MaterialEditor.EnableInstancingField(); m_MaterialEditor.DoubleSidedGIField(); }
public void PropertiesDefaultGUI(MaterialEditor materialEditor) { var f = materialEditor.GetType().GetField("m_InfoMessage", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); if (f != null) { string m_InfoMessage = (string)f.GetValue(materialEditor); materialEditor.SetDefaultGUIWidths(); if (m_InfoMessage != null) { EditorGUILayout.HelpBox(m_InfoMessage, MessageType.Info); } else { GUIUtility.GetControlID(s_ControlHash, FocusType.Passive, new Rect(0f, 0f, 0f, 0f)); } } foreach (var props in s_GraphProperty.Values) { MaterialProperty prop = props.title; if ((prop.flags & (MaterialProperty.PropFlags.HideInInspector | MaterialProperty.PropFlags.PerRendererData)) == MaterialProperty.PropFlags.None) { if (props.child != null && props.child.Count > 0) { //如果发现有面板,使用Foldout来绘制 prop.floatValue = Convert.ToSingle(EditorGUILayout.Foldout(Convert.ToBoolean(prop.floatValue), prop.displayName)); if (prop.floatValue == 1f) { foreach (var child in props.child) { DrawGUI(materialEditor, child.title, true); } } } else { DrawGUI(materialEditor, prop, false); } } } EditorGUILayout.Space(); EditorGUILayout.Space(); if (SupportedRenderingFeatures.active.editableMaterialRenderQueue) { materialEditor.RenderQueueField(); } materialEditor.EnableInstancingField(); materialEditor.DoubleSidedGIField(); //unity 2020 新版本功能 ,老版本需要注释掉 materialEditor.EmissionEnabledProperty(); }
public override void OnGUI(MaterialEditor editor, MaterialProperty[] props) { FetchProperties(props); if (IsFirstTimeApply) { ApplyMaterialChange((Material)editor.target); IsFirstTimeApply = false; } editor.SetDefaultGUIWidths(); BasicProperties(editor, props); EditorGUILayout.Space(); EditorGUILayout.Space(); var hasModified = false; EditorGUI.BeginChangeCheck(); { AdvancedProperties(editor, props); EditorGUILayout.Space(); EditorGUILayout.Space(); } hasModified = EditorGUI.EndChangeCheck(); editor.RenderQueueField(); EditorGUI.BeginChangeCheck(); { if (EnablePerInstanceDataProperty != null) { editor.EnableInstancingField(); Property(editor, EnablePerInstanceDataProperty); } } hasModified = EditorGUI.EndChangeCheck() || hasModified; editor.DoubleSidedGIField(); if (hasModified) { foreach (var target in SurfaceProperty.targets) { ApplyMaterialChange((Material)target); } } }
private void DrawOptionsBox(MaterialEditor materialEditor, Material[] materials) { EditorGUILayout.LabelField("Options", EditorStyles.boldLabel); EditorGUILayout.BeginVertical(GUI.skin.box); { #if UNITY_5_6_OR_NEWER // materialEditor.EnableInstancingField(); materialEditor.DoubleSidedGIField(); #endif materialEditor.RenderQueueField(); } EditorGUILayout.EndVertical(); EditorGUILayout.Space(); }
public static void DrawShaderGraphGUI(MaterialEditor materialEditor, IEnumerable <MaterialProperty> properties, IEnumerable <MinimalCategoryData> categoryDatas) { foreach (MinimalCategoryData mcd in categoryDatas) { DrawCategory(materialEditor, properties, mcd); } EditorGUILayout.Space(); EditorGUILayout.Space(); if (SupportedRenderingFeatures.active.editableMaterialRenderQueue) { materialEditor.RenderQueueField(); } materialEditor.EnableInstancingField(); materialEditor.DoubleSidedGIField(); }
public override void OnGUI(MaterialEditor editor, MaterialProperty[] aProp) { var _AlphaCutoutThreshold = FindProperty("_AlphaCutoutThreshold", aProp); editor.ShaderProperty(_AlphaCutoutThreshold, _AlphaCutoutThreshold.displayName); var _Dithering = FindProperty("_Dithering", aProp); editor.ShaderProperty(_Dithering, _Dithering.displayName); var _DitherTexture = FindProperty("_DitherTexture", aProp); editor.ShaderProperty(_DitherTexture, _DitherTexture.displayName); var _DitherTextureSize = FindProperty("_DitherTextureSize", aProp); editor.ShaderProperty(_DitherTextureSize, _DitherTextureSize.displayName); var _RandomDither = FindProperty("_RandomDither", aProp); editor.ShaderProperty(_RandomDither, _RandomDither.displayName); EditorGUILayout.Space(); var _UseTex0 = FindProperty("_UseTex0", aProp); editor.ShaderProperty(_UseTex0, _UseTex0.displayName); if (_UseTex0.floatValue > 0.0f) { var _MainTex = FindProperty("_MainTex", aProp); var _MainTexX = FindProperty("_MainTexX", aProp); var _MainTexY = FindProperty("_MainTexY", aProp); var _MainTexZ = FindProperty("_MainTexZ", aProp); editor.ShaderProperty(_MainTex, _MainTex.displayName); editor.ShaderProperty(_MainTexX, _MainTexX.displayName); editor.ShaderProperty(_MainTexY, _MainTexY.displayName); editor.ShaderProperty(_MainTexZ, _MainTexZ.displayName); EditorGUILayout.Space(); } EditorGUILayout.Space(); editor.RenderQueueField(); editor.DoubleSidedGIField(); }
public void ShaderPropertiesGUI(Material material) { EditorGUI.BeginChangeCheck(); { BlendModePopup(); EditorGUILayout.Space(); DoAlbedo(material); EditorGUILayout.Space(); DoNormal(material); EditorGUILayout.Space(); DoPBR(material); EditorGUILayout.Space(); DoEmission(material); EditorGUILayout.Space(); DoCullMode(material); EditorGUILayout.Space(); _materialEditor.RenderQueueField(); _materialEditor.DoubleSidedGIField(); } }
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties) { materialEditor.SetDefaultGUIWidths(); OnGUIRenderingMode(materialEditor, properties); OnGUIBasicProperties(materialEditor, properties); foreach (var propertyGroup in PropertyGroups) { if (OnGUIPropertyGroup(propertyGroup, materialEditor, properties)) { EditorGUILayout.Space(); } } EditorGUILayout.Space(); materialEditor.RenderQueueField(); materialEditor.EnableInstancingField(); materialEditor.DoubleSidedGIField(); }
void ShaderPropertiesGUI(Material material) { EditorGUIUtility.labelWidth = 0f; DoAlbedoArea(); EditorGUILayout.Space(); DoNormalArea(); EditorGUILayout.Space(); if (DoCutoutArea()) { EditorGUILayout.Space(); } if (DoAlphaArea()) { EditorGUILayout.Space(); } DoSmoothnessArea(); EditorGUILayout.Space(); DoMetallicArea(); EditorGUILayout.Space(); DoEmissionArea(); EditorGUILayout.Space(); DoTintArea(); StandardShaderHelper.ComputeFlagsAndKeywords(material); EditorGUILayout.Space(); GUILayout.Label("Advanced", EditorStyles.boldLabel); m_MaterialEditor.EnableInstancingField(); m_MaterialEditor.DoubleSidedGIField(); }
private void OtherGUI() { materialEditor.RenderQueueField(); materialEditor.EnableInstancingField(); materialEditor.DoubleSidedGIField(); }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; bool maskEnabled = material.IsKeywordEnabled("_PATTERN_MASK"); // Detect any changes to the material EditorGUI.BeginChangeCheck(); { //BlendModePopup(); // Primary properties GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel); m_MaterialEditor.TexturePropertySingleLine(Styles.detailMaskText, detailMask); DoAlbedoArea(material); if (detailMask.textureValue != null) { DoSpecularMetallicArea(); } if (specularColor != null) { m_MaterialEditor.ColorProperty(specularColor, Styles.specularColorText.text); } 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); 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); maskEnabled = EditorGUILayout.Toggle(Styles.maskEnabledText, maskEnabled); m_MaterialEditor.ShaderProperty(uvSetSecondary, Styles.uvSetLabel.text); m_MaterialEditor.TextureScaleOffsetProperty(dfTextureMap); m_MaterialEditor.ShaderProperty(pushAmount, "Push Amount"); //// 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); } if (maskEnabled) { material.EnableKeyword("_PATTERN_MASK"); } else { material.DisableKeyword("_PATTERN_MASK"); } } EditorGUILayout.Space(); GUILayout.Label(Styles.advancedText, EditorStyles.boldLabel); m_MaterialEditor.RenderQueueField(); 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(); // 4 Layers properties // layer 1 GUILayout.Label(Styles.firstMapsText, EditorStyles.boldLabel); DoAlbedoArea(material, Styles.albedo1Text, albedoMap1, Styles.materialScale1Text, materialScale1); DoSpecularMetallicArea(Styles.specularMap1Text, specularMap1, Styles.metallicMap1Text, metallicMap1); DoNormalArea(Styles.normalMap1Text, bumpMap1); // layer 2 GUILayout.Label(Styles.secondMapsText, EditorStyles.boldLabel); DoAlbedoArea(material, Styles.albedo2Text, albedoMap2, Styles.materialScale2Text, materialScale2); DoSpecularMetallicArea(Styles.specularMap2Text, specularMap2, Styles.metallicMap2Text, metallicMap2); DoNormalArea(Styles.normalMap2Text, bumpMap2); m_MaterialEditor.ShaderProperty(enableThirdLayerMaps, Styles.enableThirdLayerMapsText); if (enableThirdLayerMaps.floatValue == 1.0) { // layer 3 GUILayout.Label(Styles.thirdMapsText, EditorStyles.boldLabel); DoAlbedoArea(material, Styles.albedo3Text, albedoMap3, Styles.materialScale3Text, materialScale3); DoSpecularMetallicArea(Styles.specularMap3Text, specularMap3, Styles.metallicMap3Text, metallicMap3); DoNormalArea(Styles.normalMap3Text, bumpMap3); } m_MaterialEditor.ShaderProperty(enableFourthLayerMaps, Styles.enableFourthLayerMapsText); if (enableFourthLayerMaps.floatValue == 1.0) { // layer 4 GUILayout.Label(Styles.fourthMapsText, EditorStyles.boldLabel); DoAlbedoArea(material, Styles.albedo4Text, albedoMap4, Styles.materialScale4Text, materialScale4); DoSpecularMetallicArea(Styles.specularMap4Text, specularMap4, Styles.metallicMap4Text, metallicMap4); DoNormalArea(Styles.normalMap4Text, bumpMap4); } // mask layer GUILayout.Label(Styles.maskMapsText, EditorStyles.boldLabel); m_MaterialEditor.TexturePropertySingleLine(Styles.maskText, maskMap); // mesh normal GUILayout.Label(Styles.meshNormalMapsText, EditorStyles.boldLabel); m_MaterialEditor.TexturePropertySingleLine(Styles.meshNormalMapText, meshBumpMap); // other settings GUILayout.Label(Styles.otherSettingText, EditorStyles.boldLabel); 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(albedoMap1); if (EditorGUI.EndChangeCheck()) { emissionMap.textureScaleAndOffset = albedoMap1.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); } BoolPropertyChanged(enableThirdLayerMaps, _enableThirdLayerMapsKeyword); BoolPropertyChanged(enableFourthLayerMaps, _enableFourthLayerMapsKeyword); } 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 DrawDynamicInspector(Material material, MaterialEditor materialEditor, MaterialProperty[] props, bool isSingleMaterial) { var customPropsList = new List <MaterialProperty>(); for (int i = 0; i < props.Length; i++) { var prop = props[i]; if (prop.flags == MaterialProperty.PropFlags.HideInInspector) { continue; } if (material.HasProperty("_RenderMode")) { if (material.GetInt("_RenderMode") == 0 && prop.name == "_RenderBlend") { continue; } if (material.GetInt("_RenderMode") == 0 && prop.name == "_RenderZWrite") { continue; } if (material.GetInt("_RenderMode") == 0 && prop.name == "_RenderPriority") { continue; } } if (material.HasProperty("_LocalColors")) { if (prop.name == "_LocalColors") { continue; } } if (!material.HasProperty("_SecondColor")) { if (prop.name == "_DetailCat") { continue; } if (prop.name == "_DetailMode") { continue; } if (prop.name == "_DetailTypeMode") { continue; } if (prop.name == "_DetailMapsMode") { continue; } if (prop.name == "_DetailSpace") { continue; } } if (!material.HasProperty("_IsPropShader")) { if (prop.name == "_DetailTypeMode") { continue; } } if (material.HasProperty("_DetailTypeMode")) { if (material.GetInt("_DetailTypeMode") == 0 && prop.name == "_DetailProjectionMode") { continue; } if (material.GetInt("_DetailTypeMode") == 1 && prop.name == "_DetailCoordMode") { continue; } } if (material.HasProperty("_DetailMapsMode")) { if (material.GetInt("_DetailMapsMode") == 0 && prop.name == "_SecondPackedTex") { continue; } if (material.GetInt("_DetailMapsMode") == 1 && prop.name == "_SecondAlbedoTex") { continue; } if (material.GetInt("_DetailMapsMode") == 1 && prop.name == "_SecondNormalTex") { continue; } if (material.GetInt("_DetailMapsMode") == 1 && prop.name == "_SecondMetallicValue") { continue; } if (material.GetInt("_DetailMapsMode") == 1 && prop.name == "_SecondOcclusionValue") { continue; } } if (material.HasProperty("_VertexDataMode")) { if (material.GetInt("_VertexDataMode") == 1 && prop.name == "_VertexMotionMode") { continue; } if (material.GetInt("_VertexDataMode") == 1 && prop.name == "_VertexPivotMode") { continue; } if (material.GetInt("_VertexDataMode") == 1 && prop.name == "_VertexMotionSpace") { continue; } if (material.GetInt("_VertexDataMode") == 1 && prop.name == "_ObjectDataMessage") { continue; } if (material.GetInt("_VertexDataMode") == 1 && prop.name == "_WorldDataMessage") { continue; } if (material.GetInt("_VertexDataMode") == 1 && prop.name == "_PivotsMessage") { continue; } } customPropsList.Add(prop); } //Draw Default GUI //var customPropsArr = new MaterialProperty[customPropsList.Count]; //for (int i = 0; i < customPropsList.Count; i++) //{ // customPropsArr[i] = customPropsList[i]; //} //materialEditor.PropertiesDefaultGUI(customPropsArr); //return; //Draw Custom GUI for (int i = 0; i < customPropsList.Count; i++) { var prop = customPropsList[i]; if (prop.type == MaterialProperty.PropType.Texture) { EditorGUI.showMixedValue = !isSingleMaterial; var tex = (Texture2D)EditorGUILayout.ObjectField(prop.displayName, prop.textureValue, typeof(Texture2D), true, GUILayout.Height(50)); prop.textureValue = tex; EditorGUI.showMixedValue = false; } else { materialEditor.ShaderProperty(customPropsList[i], customPropsList[i].displayName); } } materialEditor.EnableInstancingField(); GUILayout.Space(10); materialEditor.DoubleSidedGIField(); materialEditor.LightmapEmissionProperty(0); GUILayout.Space(10); materialEditor.RenderQueueField(); GUILayout.Space(10); //TheVegetationEngine.TVEShaderUtils.DrawMaterialVersion(material); }
///<inheritdoc /> public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties) { Undo.undoRedoPerformed += () => { materialEditor.Repaint(); }; var material = materialEditor.target as Material; if (material == null) { return; } if (materialEditor.isVisible) { using (new GUILayout.HorizontalScope()) { if (GUILayout.Button("Copy Values")) { SaveMaterialProperties(material); } if (GUILayout.Button("Past Values")) { LoadMaterialProperties(material); materialEditor.PropertiesChanged(); } } using (new GUILayout.HorizontalScope()) { if (GUILayout.Button("Export Template")) { SaveTemplateData(material); } if (GUILayout.Button("Import Template")) { LoadTemplateData(material); materialEditor.PropertiesChanged(); } } GUILayout.Space(5); } var transparentMaskProp = FindProperty(this.transparentMask, properties, false); var transparencyProp = FindProperty(this.transparency, properties, false); var transparentisBaseTextureProp = FindProperty(this.transparentisBaseTexture, properties, false); var mainTexureProp = FindProperty(this.mainTexure, properties, false); var baseColorProp = FindProperty(this.baseColor, properties, false); var stShadeMapProp = FindProperty(this.stShadeMap, properties, false); var stShadeColorProp = FindProperty(this.stShadeColor, properties, false); var ndShadeMapProp = FindProperty(this.ndShadeMap, properties, false); var ndShadeColorProp = FindProperty(this.ndShadeColor, properties, false); var baseColorStepProp = FindProperty(this.baseColorStep, properties, false); var baseShadeSoftnessProp = FindProperty(this.baseShadeSoftness, properties, false); var shadeColorStepProp = FindProperty(this.shadeColorStep, properties, false); var st2ndShadeSoftnessProp = FindProperty(this.st2ndShadeSoftness, properties, false); var normalProp = FindProperty(this.normal, properties, false); var normalScaleProp = FindProperty(this.normalScale, properties, false); var useRimProp = FindProperty(this.useRim, properties, false); var rimColorProp = FindProperty(this.rimColor, properties, false); var rimLightMaskProp = FindProperty(this.rimLightMask, properties, false); var rimPowerProp = FindProperty(this.rimPower, properties, false); var rimOffsetProp = FindProperty(this.rimOffset, properties, false); var rimBiasProp = FindProperty(this.rimBias, properties, false); var useSubsurfaceProp = FindProperty(this.useSubsurface, properties, false); var sSSMapProp = FindProperty(this.sSSMap, properties, false); var sSSMultiplierProp = FindProperty(this.sSSMultiplier, properties, false); var sSSColorProp = FindProperty(this.sSSColor, properties, false); var sSSColorPowerProp = FindProperty(this.sSSColorPower, properties, false); var sSSScaleProp = FindProperty(this.sSSScale, properties, false); var sSSPowerProp = FindProperty(this.sSSPower, properties, false); var shadowStrengthProp = FindProperty(this.shadowStrength, properties, false); var pointLightPunchthroughProp = FindProperty(this.pointLightPunchthrough, properties, false); var subsurfaceDistortionProp = FindProperty(this.subsurfaceDistortion, properties, false); var matcapProp = FindProperty(this.matcap, properties, false); var matcapMaskProp = FindProperty(this.matcapMask, properties, false); var specularMaskProp = FindProperty(this.specularMask, properties, false); var specularColorProp = FindProperty(this.specularColor, properties, false); var specularPowerProp = FindProperty(this.specularPower, properties, false); var specularSmoothnessProp = FindProperty(this.specularSmoothness, properties, false); var metallicProp = FindProperty(this.metallic, properties, false); var smoothnessProp = FindProperty(this.smoothness, properties, false); var emmissiveMaskProp = FindProperty(this.emmissiveMask, properties, false); var emmisiveColorProp = FindProperty(this.emmisiveColor, properties, false); var unlitIntensityProp = FindProperty(this.unlitIntensity, properties, false); var maskClipValueProp = FindProperty(this.maskClipValue, properties, false); var outlineMaskProp = FindProperty(this.outlineMask, properties, false); var outlineColorProp = FindProperty(this.outlineColor, properties, false); var outlineWidth1Prop = FindProperty(this.outlineWidth1, properties, false); var baseColorToOutlineColorProp = FindProperty(this.baseColorToOutlineColor, properties, false); var referenceProp = FindProperty(this.reference, properties, false); var readMaskProp = FindProperty(this.readMask, properties, false); var writeMaskProp = FindProperty(this.writeMask, properties, false); var compFrontProp = FindProperty(this.compFront, properties, false); var passFrontProp = FindProperty(this.passFront, properties, false); var failFrontProp = FindProperty(this.failFront, properties, false); var zFailFrontProp = FindProperty(this.zFailFront, properties, false); var compBackProp = FindProperty(this.compBack, properties, false); var passBackProp = FindProperty(this.passBack, properties, false); var failBackProp = FindProperty(this.failBack, properties, false); var zFailBackProp = FindProperty(this.zFailBack, properties, false); var cullModeProp = FindProperty(this.cullMode, properties, false); using (var scope = new EditorGUI.ChangeCheckScope()) { if (this.firstInspectedEditor) { this.useRimToggle = useRimProp.floatValue > 0; this.useSubsurfaceToggle = useSubsurfaceProp.floatValue > 0; this.firstInspectedEditor = false; } CustomInspectorUIUtility.SetKeyword(useRimProp, this.useRimToggle); CustomInspectorUIUtility.SetKeyword(useSubsurfaceProp, this.useSubsurfaceToggle); materialEditor.SetDefaultGUIWidths(); CustomInspectorUIUtility.PropertyFoldGroup("Rendering", ref this.cullModeFold, () => { materialEditor.ShaderProperty(cullModeProp, "Cull Mode"); }); if (transparentMaskProp != null) { CustomInspectorUIUtility.PropertyFoldGroup("Transparency Settings", ref this.transparentMaskFold, () => { materialEditor.TexturePropertySingleLine(new GUIContent("Transparent Mask"), transparentMaskProp); materialEditor.ShaderProperty(transparencyProp, "Transparency"); materialEditor.ShaderProperty(maskClipValueProp, "Mask Clip Value"); materialEditor.ShaderProperty(transparentisBaseTextureProp, "Transparent is Base Texture"); }); } CustomInspectorUIUtility.PropertyFoldGroup("Base Map", ref this.mainTexureFold, () => { materialEditor.TexturePropertySingleLine(new GUIContent("Main Texure"), mainTexureProp); materialEditor.ShaderProperty(baseColorProp, "Base Color"); }); CustomInspectorUIUtility.PropertyFoldGroup("Shadow Settings", ref this.stShadeMapFold, () => { materialEditor.TexturePropertySingleLine(new GUIContent("1st Shade Map"), stShadeMapProp); materialEditor.ShaderProperty(stShadeColorProp, "1st Shade Color"); materialEditor.TexturePropertySingleLine(new GUIContent("2nd Shade Map"), ndShadeMapProp); materialEditor.ShaderProperty(ndShadeColorProp, "2nd Shade Color"); }); CustomInspectorUIUtility.PropertyFoldGroup("Toon Shade Settings", ref this.baseColorStepFold, () => { materialEditor.ShaderProperty(baseColorStepProp, "Base Color Step"); materialEditor.ShaderProperty(baseShadeSoftnessProp, "Base Shade Softness"); materialEditor.ShaderProperty(shadeColorStepProp, "Shade Color Step"); materialEditor.ShaderProperty(st2ndShadeSoftnessProp, "1st2nd Shade Softness"); }); CustomInspectorUIUtility.PropertyFoldGroup("Normal Settings", ref this.normalFold, () => { materialEditor.ShaderProperty(normalProp, "Normal"); materialEditor.ShaderProperty(normalScaleProp, "Normal Scale"); }); CustomInspectorUIUtility.PropertyToggleFoldGroup("Rim Settings", ref this.rimColorFold, ref this.useRimToggle, () => { materialEditor.ShaderProperty(rimLightMaskProp, "RimLight Mask"); materialEditor.ShaderProperty(rimColorProp, "Rim Color"); materialEditor.ShaderProperty(rimPowerProp, "Rim Power"); materialEditor.ShaderProperty(rimOffsetProp, "Rim Offset"); materialEditor.ShaderProperty(rimBiasProp, "Rim Bias"); }); CustomInspectorUIUtility.PropertyToggleFoldGroup("Subsurface Settings", ref this.useSubsurfaceFold, ref this.useSubsurfaceToggle, () => { materialEditor.ShaderProperty(sSSMapProp, "SSS Map"); materialEditor.ShaderProperty(sSSMultiplierProp, "SSS Multiplier"); materialEditor.ShaderProperty(sSSColorProp, "SSS Color"); materialEditor.ShaderProperty(sSSColorPowerProp, "SSS Color Power"); materialEditor.ShaderProperty(sSSScaleProp, "SSS Scale"); materialEditor.ShaderProperty(sSSPowerProp, "SSS Power"); materialEditor.ShaderProperty(shadowStrengthProp, "Shadow Strength"); materialEditor.ShaderProperty(pointLightPunchthroughProp, "Point Light Punchthrough"); materialEditor.ShaderProperty(subsurfaceDistortionProp, "Subsurface Distortion"); }); CustomInspectorUIUtility.PropertyFoldGroup("Matcap Settings", ref this.matcapFold, () => { materialEditor.TexturePropertySingleLine(new GUIContent("Matcap"), matcapProp); materialEditor.TexturePropertySingleLine(new GUIContent("Matcap Mask"), matcapMaskProp); }); CustomInspectorUIUtility.PropertyFoldGroup("Metallic Settings", ref this.metallicFold, () => { materialEditor.ShaderProperty(metallicProp, "Metallic"); materialEditor.ShaderProperty(smoothnessProp, "Smoothness"); }); CustomInspectorUIUtility.PropertyFoldGroup("Specular Settings", ref this.specularMaskFold, () => { materialEditor.TexturePropertySingleLine(new GUIContent("Specular Mask"), specularMaskProp); materialEditor.ShaderProperty(specularColorProp, "Specular Color"); materialEditor.ShaderProperty(specularPowerProp, "Specular Step"); materialEditor.ShaderProperty(specularSmoothnessProp, "Specular Softness"); }); CustomInspectorUIUtility.PropertyFoldGroup("Emmisive Settings", ref this.emmissiveMaskFold, () => { materialEditor.TexturePropertySingleLine(new GUIContent("Emmissive Mask"), emmissiveMaskProp); materialEditor.ShaderProperty(emmisiveColorProp, "Emmisive Color"); }); CustomInspectorUIUtility.PropertyFoldGroup("Light Settings", ref this.unlitIntensityFold, () => { materialEditor.ShaderProperty(unlitIntensityProp, "Unlit Intensity"); }); if (outlineMaskProp != null) { CustomInspectorUIUtility.PropertyFoldGroup("Outline Settings", ref this.outlineMaskFold, () => { materialEditor.TexturePropertySingleLine(new GUIContent("Outline Mask"), outlineMaskProp); materialEditor.ShaderProperty(outlineColorProp, "Outline Color"); materialEditor.ShaderProperty(outlineWidth1Prop, "Outline Width"); }); } CustomInspectorUIUtility.PropertyFoldGroup("Stencil Buffer", ref this.referenceFold, () => { materialEditor.ShaderProperty(referenceProp, "Reference"); materialEditor.ShaderProperty(readMaskProp, "Read Mask"); materialEditor.ShaderProperty(writeMaskProp, "Write Mask"); materialEditor.ShaderProperty(compFrontProp, "Comp. Front"); materialEditor.ShaderProperty(passFrontProp, "Pass Front"); materialEditor.ShaderProperty(failFrontProp, "Fail Front"); materialEditor.ShaderProperty(zFailFrontProp, "ZFail Front"); materialEditor.ShaderProperty(compBackProp, "Comp. Back"); materialEditor.ShaderProperty(passBackProp, "Pass Back"); materialEditor.ShaderProperty(failBackProp, "Fail Back"); materialEditor.ShaderProperty(zFailBackProp, "ZFail Back"); }); CustomInspectorUIUtility.PropertyFoldGroup("Other", ref this.renderingFold, () => { materialEditor.RenderQueueField(); #if UNITY_5_6_OR_NEWER materialEditor.EnableInstancingField(); #endif #if UNITY_5_6_2 || UNITY_5_6_3 || UNITY_5_6_4 || UNITY_2017_1_OR_NEWER materialEditor.DoubleSidedGIField(); #endif materialEditor.LightmapEmissionProperty(); }); } }
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties) { _debugMode = FindProperty("_DebugMode", properties); _outlineWidthMode = FindProperty("_OutlineWidthMode", properties); _outlineColorMode = FindProperty("_OutlineColorMode", properties); _blendMode = FindProperty("_BlendMode", properties); _cullMode = FindProperty("_CullMode", properties); _outlineCullMode = FindProperty("_OutlineCullMode", properties); _cutoff = FindProperty("_Cutoff", properties); _color = FindProperty("_Color", properties); _shadeColor = FindProperty("_ShadeColor", properties); _mainTex = FindProperty("_MainTex", properties); _shadeTexture = FindProperty("_ShadeTexture", properties); _bumpScale = FindProperty("_BumpScale", properties); _bumpMap = FindProperty("_BumpMap", properties); _receiveShadowRate = FindProperty("_ReceiveShadowRate", properties); _receiveShadowTexture = FindProperty("_ReceiveShadowTexture", properties); _shadeShift = FindProperty("_ShadeShift", properties); _shadeToony = FindProperty("_ShadeToony", properties); _lightColorAttenuation = FindProperty("_LightColorAttenuation", properties); _sphereAdd = FindProperty("_SphereAdd", properties); _emissionColor = FindProperty("_EmissionColor", properties); _emissionMap = FindProperty("_EmissionMap", properties); _outlineWidthTexture = FindProperty("_OutlineWidthTexture", properties); _outlineWidth = FindProperty("_OutlineWidth", properties); _outlineScaledMaxDistance = FindProperty("_OutlineScaledMaxDistance", properties); _outlineColor = FindProperty("_OutlineColor", properties); _outlineLightingMix = FindProperty("_OutlineLightingMix", properties); _isFirstSetup = FindProperty("_IsFirstSetup", properties); var uvMappedTextureProperties = new[] { _mainTex, _shadeTexture, _bumpMap, _receiveShadowTexture, _emissionMap, _outlineWidthTexture }; foreach (var obj in materialEditor.targets) { var mat = (Material)obj; var isFirstSetup = mat.GetFloat(_isFirstSetup.name); if (isFirstSetup < 0.5f) { continue; } mat.SetFloat(_isFirstSetup.name, 0.0f); var mainTex = mat.GetTexture(_mainTex.name); var shadeTex = mat.GetTexture(_shadeTexture.name); if (mainTex != null && shadeTex == null) { mat.SetTexture(_shadeTexture.name, mainTex); } } foreach (var obj in materialEditor.targets) { var mat = (Material)obj; SetupBlendMode(mat, (RenderMode)mat.GetFloat(_blendMode.name)); SetupNormalMode(mat, mat.GetTexture(_bumpMap.name)); SetupOutlineMode(mat, (OutlineWidthMode)mat.GetFloat(_outlineWidthMode.name), (OutlineColorMode)mat.GetFloat(_outlineColorMode.name)); SetupDebugMode(mat, (DebugMode)mat.GetFloat(_debugMode.name)); SetupCullMode(mat, (CullMode)mat.GetFloat(_cullMode.name)); } EditorGUI.BeginChangeCheck(); { EditorGUILayout.LabelField("Basic", EditorStyles.boldLabel); EditorGUILayout.BeginVertical(GUI.skin.box); { EditorGUILayout.LabelField("Mode", EditorStyles.boldLabel); var bm = (RenderMode)_blendMode.floatValue; if (PopupEnum <RenderMode>("Rendering Type", _blendMode, materialEditor)) { bm = (RenderMode)_blendMode.floatValue; foreach (var obj in materialEditor.targets) { SetupBlendMode((Material)obj, bm); } } EditorGUI.showMixedValue = false; if (PopupEnum <CullMode>("Cull Mode", _cullMode, materialEditor)) { var cm = (CullMode)_cullMode.floatValue; foreach (var obj in materialEditor.targets) { SetupCullMode((Material)obj, cm); } } EditorGUI.showMixedValue = false; EditorGUILayout.Space(); if (bm != RenderMode.Opaque) { EditorGUILayout.LabelField("Alpha", EditorStyles.boldLabel); { if (bm == RenderMode.Transparent || bm == RenderMode.Mixed) { EditorGUILayout.TextField("Ensure your lit color and texture have alpha channels."); } if (bm == RenderMode.Cutout) { EditorGUILayout.TextField("Ensure your lit color and texture have alpha channels."); materialEditor.ShaderProperty(_cutoff, "Cutoff"); } } EditorGUILayout.Space(); } EditorGUILayout.LabelField("Color", EditorStyles.boldLabel); { // Color materialEditor.TexturePropertySingleLine(new GUIContent("Lit & Alpha", "Lit (RGB), Alpha (A)"), _mainTex, _color); materialEditor.TexturePropertySingleLine(new GUIContent("Shade", "Shade (RGB)"), _shadeTexture, _shadeColor); } } EditorGUILayout.EndVertical(); EditorGUILayout.Space(); EditorGUILayout.LabelField("Lighting", EditorStyles.boldLabel); EditorGUILayout.BeginVertical(GUI.skin.box); { EditorGUILayout.LabelField("Shade", EditorStyles.boldLabel); { // Shade materialEditor.ShaderProperty(_shadeShift, "Shift"); materialEditor.ShaderProperty(_shadeToony, "Toony"); materialEditor.ShaderProperty(_lightColorAttenuation, "LightColor Attenuation"); } EditorGUILayout.Space(); EditorGUILayout.LabelField("Shadow", EditorStyles.boldLabel); { // Shadow if (((Material)materialEditor.target).GetFloat("_ShadeShift") < 0f) { EditorGUILayout.LabelField( "Receive rate should be lower value when Shade Shift is lower than 0.", EditorStyles.wordWrappedLabel); } materialEditor.TexturePropertySingleLine( new GUIContent("Receive Rate", "Receive Shadow Rate Map (A)"), _receiveShadowTexture, _receiveShadowRate); } EditorGUILayout.Space(); EditorGUILayout.LabelField("Rim", EditorStyles.boldLabel); { // Rim Light materialEditor.TexturePropertySingleLine(new GUIContent("Additive", "Rim Additive Texture (RGB)"), _sphereAdd); } EditorGUILayout.Space(); EditorGUILayout.LabelField("Emission", EditorStyles.boldLabel); { materialEditor.TexturePropertySingleLine(new GUIContent("Emission", "Emission (RGB)"), _emissionMap, _emissionColor); } EditorGUILayout.Space(); EditorGUILayout.LabelField("Normal", EditorStyles.boldLabel); { // Normal EditorGUI.BeginChangeCheck(); materialEditor.TexturePropertySingleLine(new GUIContent("Normal Map", "Normal Map (RGB)"), _bumpMap, _bumpScale); if (EditorGUI.EndChangeCheck()) { materialEditor.RegisterPropertyChangeUndo("BumpEnabledDisabled"); foreach (var obj in materialEditor.targets) { var mat = (Material)obj; SetupNormalMode(mat, mat.GetTexture(_bumpMap.name)); } } } } EditorGUILayout.EndVertical(); EditorGUILayout.Space(); EditorGUILayout.LabelField("Outline", EditorStyles.boldLabel); EditorGUILayout.BeginVertical(GUI.skin.box); { EditorGUILayout.LabelField("Width", EditorStyles.boldLabel); { // Outline EditorGUI.BeginChangeCheck(); PopupEnum <OutlineWidthMode>("Mode", _outlineWidthMode, materialEditor); var widthMode = (OutlineWidthMode)_outlineWidthMode.floatValue; if (widthMode != OutlineWidthMode.None) { materialEditor.TexturePropertySingleLine( new GUIContent("Width", "Outline Width Texture (RGB)"), _outlineWidthTexture, _outlineWidth); } if (widthMode == OutlineWidthMode.ScreenCoordinates) { materialEditor.ShaderProperty(_outlineScaledMaxDistance, "Width Scaled Max Distance"); } if (EditorGUI.EndChangeCheck()) { var colorMode = (OutlineColorMode)_outlineColorMode.floatValue; foreach (var obj in materialEditor.targets) { SetupOutlineMode((Material)obj, widthMode, colorMode); } } } EditorGUILayout.Space(); EditorGUILayout.LabelField("Color", EditorStyles.boldLabel); { var widthMode = (OutlineWidthMode)_outlineWidthMode.floatValue; if (widthMode != OutlineWidthMode.None) { EditorGUI.BeginChangeCheck(); PopupEnum <OutlineColorMode>("Mode", _outlineColorMode, materialEditor); var colorMode = (OutlineColorMode)_outlineColorMode.floatValue; materialEditor.ShaderProperty(_outlineColor, "Color"); if (colorMode == OutlineColorMode.MixedLighting) { materialEditor.DefaultShaderProperty(_outlineLightingMix, "Lighting Mix"); } if (EditorGUI.EndChangeCheck()) { foreach (var obj in materialEditor.targets) { SetupOutlineMode((Material)obj, widthMode, colorMode); } } } } } EditorGUILayout.EndVertical(); EditorGUILayout.Space(); EditorGUILayout.LabelField("Options", EditorStyles.boldLabel); EditorGUILayout.BeginVertical(GUI.skin.box); { EditorGUILayout.LabelField("Texture Options", EditorStyles.boldLabel); { EditorGUI.BeginChangeCheck(); materialEditor.TextureScaleOffsetProperty(_mainTex); if (EditorGUI.EndChangeCheck()) { foreach (var textureProperty in uvMappedTextureProperties) { textureProperty.textureScaleAndOffset = _mainTex.textureScaleAndOffset; } } } EditorGUILayout.Space(); EditorGUILayout.LabelField("Debugging Options", EditorStyles.boldLabel); { if (PopupEnum <DebugMode>("Visualize", _debugMode, materialEditor)) { var mode = (DebugMode)_debugMode.floatValue; foreach (var obj in materialEditor.targets) { SetupDebugMode((Material)obj, mode); } } } EditorGUILayout.Space(); EditorGUILayout.LabelField("Advanced Options", EditorStyles.boldLabel); { #if UNITY_5_6_OR_NEWER materialEditor.EnableInstancingField(); materialEditor.DoubleSidedGIField(); #endif materialEditor.RenderQueueField(); } } EditorGUILayout.EndVertical(); EditorGUILayout.Space(); } EditorGUI.EndChangeCheck(); }
private void Draw(MaterialEditor materialEditor, Material[] materials) { EditorGUI.BeginChangeCheck(); { _version.floatValue = Utils.VersionNumber; EditorGUILayout.LabelField("Rendering", EditorStyles.boldLabel); EditorGUILayout.BeginVertical(GUI.skin.box); { EditorGUILayout.LabelField("Mode", EditorStyles.boldLabel); if (PopupEnum <RenderMode>("Rendering Type", _blendMode, materialEditor)) { ModeChanged(materials, isBlendModeChangedByUser: true); } if ((RenderMode)_blendMode.floatValue == RenderMode.TransparentWithZWrite) { EditorGUILayout.HelpBox("TransparentWithZWrite mode can cause problems with rendering.", MessageType.Warning); } if (PopupEnum <CullMode>("Cull Mode", _cullMode, materialEditor)) { ModeChanged(materials); } } EditorGUILayout.EndVertical(); EditorGUILayout.Space(); EditorGUILayout.LabelField("Color", EditorStyles.boldLabel); EditorGUILayout.BeginVertical(GUI.skin.box); { EditorGUILayout.LabelField("Texture", EditorStyles.boldLabel); { materialEditor.TexturePropertySingleLine(new GUIContent("Lit Color, Alpha", "Lit (RGB), Alpha (A)"), _mainTex, _color); materialEditor.TexturePropertySingleLine(new GUIContent("Shade Color", "Shade (RGB)"), _shadeTexture, _shadeColor); } var bm = (RenderMode)_blendMode.floatValue; if (bm == RenderMode.Cutout) { EditorGUILayout.Space(); EditorGUILayout.LabelField("Alpha", EditorStyles.boldLabel); { materialEditor.ShaderProperty(_cutoff, "Cutoff"); } } } EditorGUILayout.EndVertical(); EditorGUILayout.Space(); EditorGUILayout.LabelField("Lighting", EditorStyles.boldLabel); EditorGUILayout.BeginVertical(GUI.skin.box); { { materialEditor.ShaderProperty(_shadeToony, new GUIContent("Shading Toony", "0.0 is Lambert. Higher value get toony shading.")); // Normal EditorGUI.BeginChangeCheck(); materialEditor.TexturePropertySingleLine(new GUIContent("Normal Map [Normal]", "Normal Map (RGB)"), _bumpMap, _bumpScale); if (EditorGUI.EndChangeCheck()) { materialEditor.RegisterPropertyChangeUndo("BumpEnabledDisabled"); ModeChanged(materials); } } EditorGUILayout.Space(); EditorGUI.indentLevel++; { isAdvancedLightingPanelFoldout = EditorGUILayout.Foldout(isAdvancedLightingPanelFoldout, "Advanced Settings", EditorStyles.boldFont); if (isAdvancedLightingPanelFoldout) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.HelpBox( "The default settings are suitable for Advanced Settings if you want to toony result.", MessageType.Info); if (GUILayout.Button("Use Default")) { _shadeShift.floatValue = 0; _receiveShadowTexture.textureValue = null; _receiveShadowRate.floatValue = 1; _shadingGradeTexture.textureValue = null; _shadingGradeRate.floatValue = 1; _lightColorAttenuation.floatValue = 0; _indirectLightIntensity.floatValue = 0.1f; } EditorGUILayout.EndHorizontal(); materialEditor.ShaderProperty(_shadeShift, new GUIContent("Shading Shift", "Zero is Default. Negative value increase lit area. Positive value increase shade area.")); materialEditor.TexturePropertySingleLine( new GUIContent("Shadow Receive Multiplier", "Texture (R) * Rate. White is Default. Black attenuates shadows."), _receiveShadowTexture, _receiveShadowRate); materialEditor.TexturePropertySingleLine( new GUIContent("Lit & Shade Mixing Multiplier", "Texture (R) * Rate. Compatible with UTS2 ShadingGradeMap. White is Default. Black amplifies shade."), _shadingGradeTexture, _shadingGradeRate); materialEditor.ShaderProperty(_lightColorAttenuation, "LightColor Attenuation"); materialEditor.ShaderProperty(_indirectLightIntensity, "GI Intensity"); } } EditorGUI.indentLevel--; } EditorGUILayout.EndVertical(); EditorGUILayout.Space(); EditorGUILayout.LabelField("Emission", EditorStyles.boldLabel); EditorGUILayout.BeginVertical(GUI.skin.box); { TextureWithHdrColor(materialEditor, "Emission", "Emission (RGB)", _emissionMap, _emissionColor); materialEditor.TexturePropertySingleLine(new GUIContent("MatCap", "MatCap Texture (RGB)"), _sphereAdd); } EditorGUILayout.EndVertical(); EditorGUILayout.Space(); EditorGUILayout.LabelField("Rim", EditorStyles.boldLabel); EditorGUILayout.BeginVertical(GUI.skin.box); { TextureWithHdrColor(materialEditor, "Color", "Rim Color (RGB)", _rimTexture, _rimColor); materialEditor.DefaultShaderProperty(_rimLightingMix, "Lighting Mix"); materialEditor.ShaderProperty(_rimFresnelPower, new GUIContent("Fresnel Power", "If you increase this value, you get sharpness rim light.")); materialEditor.ShaderProperty(_rimLift, new GUIContent("Lift", "If you increase this value, you can lift rim light.")); } EditorGUILayout.EndVertical(); EditorGUILayout.Space(); EditorGUILayout.LabelField("Outline", EditorStyles.boldLabel); EditorGUILayout.BeginVertical(GUI.skin.box); { // Outline EditorGUILayout.LabelField("Width", EditorStyles.boldLabel); { if (PopupEnum <OutlineWidthMode>("Mode", _outlineWidthMode, materialEditor)) { ModeChanged(materials); } if ((RenderMode)_blendMode.floatValue == RenderMode.Transparent && (OutlineWidthMode)_outlineWidthMode.floatValue != OutlineWidthMode.None) { EditorGUILayout.HelpBox("Outline with Transparent material cause problem with rendering.", MessageType.Warning); } var widthMode = (OutlineWidthMode)_outlineWidthMode.floatValue; if (widthMode != OutlineWidthMode.None) { materialEditor.TexturePropertySingleLine( new GUIContent("Width", "Outline Width Texture (RGB)"), _outlineWidthTexture, _outlineWidth); } if (widthMode == OutlineWidthMode.ScreenCoordinates) { materialEditor.ShaderProperty(_outlineScaledMaxDistance, "Width Scaled Max Distance"); } } EditorGUILayout.Space(); EditorGUILayout.LabelField("Color", EditorStyles.boldLabel); { var widthMode = (OutlineWidthMode)_outlineWidthMode.floatValue; if (widthMode != OutlineWidthMode.None) { EditorGUI.BeginChangeCheck(); if (PopupEnum <OutlineColorMode>("Mode", _outlineColorMode, materialEditor)) { ModeChanged(materials); } var colorMode = (OutlineColorMode)_outlineColorMode.floatValue; materialEditor.ShaderProperty(_outlineColor, "Color"); if (colorMode == OutlineColorMode.MixedLighting) { materialEditor.DefaultShaderProperty(_outlineLightingMix, "Lighting Mix"); } } } } EditorGUILayout.EndVertical(); EditorGUILayout.Space(); EditorGUILayout.LabelField("UV Coordinates", EditorStyles.boldLabel); EditorGUILayout.BeginVertical(GUI.skin.box); { // UV EditorGUILayout.LabelField("Scale & Offset", EditorStyles.boldLabel); { materialEditor.TextureScaleOffsetProperty(_mainTex); } EditorGUILayout.Space(); EditorGUILayout.LabelField("Auto Animation", EditorStyles.boldLabel); { materialEditor.TexturePropertySingleLine(new GUIContent("Mask", "Auto Animation Mask Texture (R)"), _uvAnimMaskTexture); materialEditor.ShaderProperty(_uvAnimScrollX, "Scroll X (per second)"); materialEditor.ShaderProperty(_uvAnimScrollY, "Scroll Y (per second)"); materialEditor.ShaderProperty(_uvAnimRotation, "Rotation (per second)"); } } EditorGUILayout.EndVertical(); EditorGUILayout.Space(); EditorGUILayout.LabelField("Options", EditorStyles.boldLabel); EditorGUILayout.BeginVertical(GUI.skin.box); { EditorGUILayout.LabelField("Debugging Options", EditorStyles.boldLabel); { if (PopupEnum <DebugMode>("Visualize", _debugMode, materialEditor)) { ModeChanged(materials); } } EditorGUILayout.Space(); EditorGUILayout.LabelField("Advanced Options", EditorStyles.boldLabel); { #if UNITY_5_6_OR_NEWER // materialEditor.EnableInstancingField(); materialEditor.DoubleSidedGIField(); #endif EditorGUI.BeginChangeCheck(); materialEditor.RenderQueueField(); if (EditorGUI.EndChangeCheck()) { ModeChanged(materials); } } } EditorGUILayout.EndVertical(); EditorGUILayout.Space(); } EditorGUI.EndChangeCheck(); }
static void DrawProperties(MaterialEditor materialEditor, MaterialProperty[] properties) { materialEditor.SetDefaultGUIWidths(); EditorGUI.BeginChangeCheck(); MaterialProperty materialFlagesProp = FindProperty(MaterialFlagsPropName, properties); MaterialFlags materialFlags = (MaterialFlags)materialFlagesProp.floatValue; MaterialFlags mixedValueMaterialFlags = MaterialFlags.None; if (materialFlagesProp.hasMixedValue) { mixedValueMaterialFlags = GetMixedValueMaterialFlags(materialEditor); } MaterialProperty renderingModeProp = DrawProperty(RenderingModePropName, materialEditor, properties); DrawProperty(MainTexPropName, materialEditor, properties); bool noMaskScaleOffset = GetMaterialFlag(materialFlags, MaterialFlags.NoMaskScaleOffset); bool mixedValueNoMaskScaleOffset = GetMaterialFlag(mixedValueMaterialFlags, MaterialFlags.NoMaskScaleOffset); bool maskScaleOffset = !noMaskScaleOffset || mixedValueNoMaskScaleOffset; DrawTexure(MaskPropName, maskScaleOffset, materialEditor, properties); DrawFlagToggleProperty(s_noMaskScaleOffsetLabel, MaterialFlags.NoMaskScaleOffset, ref materialFlags, ref mixedValueMaterialFlags); DrawProperty(ColorPropName, materialEditor, properties); if ((RenderingMode)renderingModeProp.floatValue == RenderingMode.Cutout && !renderingModeProp.hasMixedValue) { DrawProperty(CutoffPropName, materialEditor, properties); } bool advancedToggle = DrawFlagFoldoutProperty(s_advancedLabel, MaterialFlags.AdvancedToggle, ref materialFlags, ref mixedValueMaterialFlags); if (advancedToggle) { EditorGUI.indentLevel++; DrawFlagToggleProperty(s_forceTextureLabel, MaterialFlags.ForceTexture, ref materialFlags, ref mixedValueMaterialFlags); DrawFlagToggleProperty(s_forceMaskLabel, MaterialFlags.ForceMask, ref materialFlags, ref mixedValueMaterialFlags); DrawFlagToggleProperty(s_forceMaskScaleOffsetLabel, MaterialFlags.ForceMaskScaleOffset, ref materialFlags, ref mixedValueMaterialFlags); DrawFlagToggleProperty(s_forceColorLabel, MaterialFlags.ForceColor, ref materialFlags, ref mixedValueMaterialFlags); DrawFlagToggleProperty(s_forceCutoffLabel, MaterialFlags.ForceCutoff, ref materialFlags, ref mixedValueMaterialFlags); EditorGUI.indentLevel--; } if (EditorGUI.EndChangeCheck()) { if (materialFlagesProp.hasMixedValue) { SetMixedValueMatrialFlags(materialEditor, materialFlags, mixedValueMaterialFlags); } else { materialFlagesProp.floatValue = (float)materialFlags; } } EditorGUILayout.Space(); EditorGUILayout.Space(); materialEditor.RenderQueueField(); materialEditor.EnableInstancingField(); materialEditor.DoubleSidedGIField(); }
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties) { IOUtils.Init(); Material mat = materialEditor.target as Material; if (mat == null) { return; } m_instance = materialEditor; if (!m_initialized) { Init(); m_initialized = true; Undo.undoRedoPerformed += UndoRedoPerformed; } if (Event.current.type == EventType.Repaint && mat.HasProperty(IOUtils.DefaultASEDirtyCheckId) && mat.GetInt(IOUtils.DefaultASEDirtyCheckId) == 1) { mat.SetInt(IOUtils.DefaultASEDirtyCheckId, 0); UIUtils.ForceUpdateFromMaterial(); //Event.current.Use(); } if (materialEditor.isVisible) { GUILayout.BeginVertical(); { GUILayout.Space(3); if (GUILayout.Button("Open in Shader Editor")) { #if UNITY_2018_3_OR_NEWER ASEPackageManagerHelper.SetupLateMaterial(mat); #else AmplifyShaderEditorWindow.LoadMaterialToASE(mat); #endif } GUILayout.BeginHorizontal(); { if (GUILayout.Button(CopyButtonStr)) { System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; Shader shader = mat.shader; int propertyCount = UnityEditor.ShaderUtil.GetPropertyCount(shader); string allProperties = string.Empty; for (int i = 0; i < propertyCount; i++) { UnityEditor.ShaderUtil.ShaderPropertyType type = UnityEditor.ShaderUtil.GetPropertyType(shader, i); string name = UnityEditor.ShaderUtil.GetPropertyName(shader, i); string valueStr = string.Empty; switch (type) { case UnityEditor.ShaderUtil.ShaderPropertyType.Color: { Color value = mat.GetColor(name); valueStr = value.r.ToString() + IOUtils.VECTOR_SEPARATOR + value.g.ToString() + IOUtils.VECTOR_SEPARATOR + value.b.ToString() + IOUtils.VECTOR_SEPARATOR + value.a.ToString(); } break; case UnityEditor.ShaderUtil.ShaderPropertyType.Vector: { Vector4 value = mat.GetVector(name); valueStr = value.x.ToString() + IOUtils.VECTOR_SEPARATOR + value.y.ToString() + IOUtils.VECTOR_SEPARATOR + value.z.ToString() + IOUtils.VECTOR_SEPARATOR + value.w.ToString(); } break; case UnityEditor.ShaderUtil.ShaderPropertyType.Float: { float value = mat.GetFloat(name); valueStr = value.ToString(); } break; case UnityEditor.ShaderUtil.ShaderPropertyType.Range: { float value = mat.GetFloat(name); valueStr = value.ToString(); } break; case UnityEditor.ShaderUtil.ShaderPropertyType.TexEnv: { Texture value = mat.GetTexture(name); valueStr = AssetDatabase.GetAssetPath(value); Vector2 offset = mat.GetTextureOffset(name); Vector2 scale = mat.GetTextureScale(name); valueStr += IOUtils.VECTOR_SEPARATOR + scale.x.ToString() + IOUtils.VECTOR_SEPARATOR + scale.y.ToString() + IOUtils.VECTOR_SEPARATOR + offset.x.ToString() + IOUtils.VECTOR_SEPARATOR + offset.y.ToString(); } break; } allProperties += name + IOUtils.FIELD_SEPARATOR + type + IOUtils.FIELD_SEPARATOR + valueStr; if (i < (propertyCount - 1)) { allProperties += IOUtils.LINE_TERMINATOR; } } EditorPrefs.SetString(IOUtils.MAT_CLIPBOARD_ID, allProperties); System.Threading.Thread.CurrentThread.CurrentCulture = System.Threading.Thread.CurrentThread.CurrentUICulture; } if (GUILayout.Button(PasteButtonStr)) { System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; string propertiesStr = EditorPrefs.GetString(IOUtils.MAT_CLIPBOARD_ID, string.Empty); if (!string.IsNullOrEmpty(propertiesStr)) { string[] propertyArr = propertiesStr.Split(IOUtils.LINE_TERMINATOR); bool validData = true; try { for (int i = 0; i < propertyArr.Length; i++) { string[] valuesArr = propertyArr[i].Split(IOUtils.FIELD_SEPARATOR); if (valuesArr.Length != 3) { Debug.LogWarning("Material clipboard data is corrupted"); validData = false; break; } else if (mat.HasProperty(valuesArr[0])) { UnityEditor.ShaderUtil.ShaderPropertyType type = (UnityEditor.ShaderUtil.ShaderPropertyType)Enum.Parse(typeof(UnityEditor.ShaderUtil.ShaderPropertyType), valuesArr[1]); switch (type) { case UnityEditor.ShaderUtil.ShaderPropertyType.Color: { string[] colorVals = valuesArr[2].Split(IOUtils.VECTOR_SEPARATOR); if (colorVals.Length != 4) { Debug.LogWarning("Material clipboard data is corrupted"); validData = false; break; } else { mat.SetColor(valuesArr[0], new Color(Convert.ToSingle(colorVals[0]), Convert.ToSingle(colorVals[1]), Convert.ToSingle(colorVals[2]), Convert.ToSingle(colorVals[3]))); } } break; case UnityEditor.ShaderUtil.ShaderPropertyType.Vector: { string[] vectorVals = valuesArr[2].Split(IOUtils.VECTOR_SEPARATOR); if (vectorVals.Length != 4) { Debug.LogWarning("Material clipboard data is corrupted"); validData = false; break; } else { mat.SetVector(valuesArr[0], new Vector4(Convert.ToSingle(vectorVals[0]), Convert.ToSingle(vectorVals[1]), Convert.ToSingle(vectorVals[2]), Convert.ToSingle(vectorVals[3]))); } } break; case UnityEditor.ShaderUtil.ShaderPropertyType.Float: { mat.SetFloat(valuesArr[0], Convert.ToSingle(valuesArr[2])); } break; case UnityEditor.ShaderUtil.ShaderPropertyType.Range: { mat.SetFloat(valuesArr[0], Convert.ToSingle(valuesArr[2])); } break; case UnityEditor.ShaderUtil.ShaderPropertyType.TexEnv: { string[] texVals = valuesArr[2].Split(IOUtils.VECTOR_SEPARATOR); if (texVals.Length != 5) { Debug.LogWarning("Material clipboard data is corrupted"); validData = false; break; } else { mat.SetTexture(valuesArr[0], AssetDatabase.LoadAssetAtPath <Texture>(texVals[0])); mat.SetTextureScale(valuesArr[0], new Vector2(Convert.ToSingle(texVals[1]), Convert.ToSingle(texVals[2]))); mat.SetTextureOffset(valuesArr[0], new Vector2(Convert.ToSingle(texVals[3]), Convert.ToSingle(texVals[4]))); } } break; } } } } catch (Exception e) { Debug.LogException(e); validData = false; } if (validData) { materialEditor.PropertiesChanged(); UIUtils.CopyValuesFromMaterial(mat); } else { EditorPrefs.SetString(IOUtils.MAT_CLIPBOARD_ID, string.Empty); } } System.Threading.Thread.CurrentThread.CurrentCulture = System.Threading.Thread.CurrentThread.CurrentUICulture; } } GUILayout.EndHorizontal(); GUILayout.Space(5); } GUILayout.EndVertical(); } EditorGUI.BeginChangeCheck(); //base.OnGUI( materialEditor, properties ); // Draw custom properties instead of calling BASE to use single line texture properties materialEditor.SetDefaultGUIWidths(); if (m_infoField == null) { m_infoField = typeof(MaterialEditor).GetField("m_InfoMessage", BindingFlags.Instance | BindingFlags.NonPublic); } string info = m_infoField.GetValue(materialEditor) as string; if (!string.IsNullOrEmpty(info)) { EditorGUILayout.HelpBox(info, MessageType.Info); } else { GUIUtility.GetControlID("EditorTextField".GetHashCode(), FocusType.Passive, new Rect(0f, 0f, 0f, 0f)); } for (int i = 0; i < properties.Length; i++) { if ((properties[i].flags & (MaterialProperty.PropFlags.HideInInspector | MaterialProperty.PropFlags.PerRendererData)) == MaterialProperty.PropFlags.None) { // Removed no scale offset one line texture property for consistency :( sad face //if( ( properties[ i ].flags & MaterialProperty.PropFlags.NoScaleOffset ) == MaterialProperty.PropFlags.NoScaleOffset ) //{ // object obj = MaterialPropertyHandlerEx.GetHandler( mat.shader, properties[ i ].name ); // if( obj != null ) // { // float height = MaterialPropertyHandlerEx.GetPropertyHeight( obj, properties[ i ], properties[ i ].displayName, materialEditor ); // //Rect rect = (Rect)materialEditor.GetType().InvokeMember( "GetPropertyRect", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod, null, materialEditor, new object[] { properties[ i ], properties[ i ].displayName, true } ); // Rect rect = EditorGUILayout.GetControlRect( true, height, EditorStyles.layerMaskField ); // MaterialPropertyHandlerEx.OnGUI( obj, ref rect, properties[ i ], new GUIContent( properties[ i ].displayName ), materialEditor ); // if( MaterialPropertyHandlerEx.PropertyDrawer( obj ) != null ) // continue; // rect = EditorGUILayout.GetControlRect( true, height, EditorStyles.layerMaskField ); // materialEditor.TexturePropertyMiniThumbnail( rect, properties[ i ], properties[ i ].displayName, string.Empty ); // } // else // { // materialEditor.TexturePropertySingleLine( new GUIContent( properties[ i ].displayName ), properties[ i ] ); // } //} //else //{ float propertyHeight = materialEditor.GetPropertyHeight(properties[i], properties[i].displayName); Rect controlRect = EditorGUILayout.GetControlRect(true, propertyHeight, EditorStyles.layerMaskField, new GUILayoutOption[0]); materialEditor.ShaderProperty(controlRect, properties[i], properties[i].displayName); //} } } EditorGUILayout.Space(); materialEditor.RenderQueueField(); #if UNITY_5_6_OR_NEWER materialEditor.EnableInstancingField(); #endif #if UNITY_5_6_2 || UNITY_5_6_3 || UNITY_5_6_4 || UNITY_2017_1_OR_NEWER materialEditor.DoubleSidedGIField(); #endif materialEditor.LightmapEmissionProperty(); if (m_refreshOnUndo || EditorGUI.EndChangeCheck()) { m_refreshOnUndo = false; string isEmissive = mat.GetTag("IsEmissive", false, "false"); if (isEmissive.Equals("true")) { mat.globalIlluminationFlags &= (MaterialGlobalIlluminationFlags)3; } else { mat.globalIlluminationFlags |= MaterialGlobalIlluminationFlags.EmissiveIsBlack; } UIUtils.CopyValuesFromMaterial(mat); } if (materialEditor.RequiresConstantRepaint() && m_lastRenderedTime + 0.032999999821186066 < EditorApplication.timeSinceStartup) { this.m_lastRenderedTime = EditorApplication.timeSinceStartup; materialEditor.Repaint(); } }
private void Draw(MaterialEditor materialEditor, Material[] materials, MaterialProperty[] uvMappedTextureProperties) { EditorGUI.BeginChangeCheck(); { EditorGUILayout.LabelField("Rendering", EditorStyles.boldLabel); EditorGUILayout.BeginVertical(GUI.skin.box); { EditorGUILayout.LabelField("Mode", EditorStyles.boldLabel); if (PopupEnum <RenderMode>("Rendering Type", _blendMode, materialEditor)) { ModeChanged(materials, isBlendModeChangedByUser: true); } if (PopupEnum <CullMode>("Cull Mode", _cullMode, materialEditor)) { ModeChanged(materials); } } EditorGUILayout.EndVertical(); EditorGUILayout.Space(); EditorGUILayout.LabelField("Color", EditorStyles.boldLabel); EditorGUILayout.BeginVertical(GUI.skin.box); { EditorGUILayout.LabelField("Texture", EditorStyles.boldLabel); { materialEditor.TexturePropertySingleLine(new GUIContent("Lit & Alpha", "Lit (RGB), Alpha (A)"), _mainTex, _color); materialEditor.TexturePropertySingleLine(new GUIContent("Shade", "Shade (RGB)"), _shadeTexture, _shadeColor); } var bm = (RenderMode)_blendMode.floatValue; if (bm != RenderMode.Opaque) { EditorGUILayout.Space(); EditorGUILayout.LabelField("Alpha", EditorStyles.boldLabel); { if (bm == RenderMode.Cutout) { materialEditor.ShaderProperty(_cutoff, "Cutoff"); } } } } EditorGUILayout.EndVertical(); EditorGUILayout.Space(); EditorGUILayout.LabelField("Lighting", EditorStyles.boldLabel); EditorGUILayout.BeginVertical(GUI.skin.box); { EditorGUILayout.LabelField("Lit & Shade Mixing", EditorStyles.boldLabel); { materialEditor.ShaderProperty(_shadeShift, new GUIContent("Shading Shift", "Zero is Default. Negative value increase lit area. Positive value increase shade area.")); materialEditor.ShaderProperty(_shadeToony, new GUIContent("Shading Toony", "0.0 is Lambert. Higher value get toony shading.")); materialEditor.TexturePropertySingleLine( new GUIContent("Shadow Receive Multiplier", "Texture (A) * Rate. White is Default. Black attenuates shadows."), _receiveShadowTexture, _receiveShadowRate); materialEditor.TexturePropertySingleLine( new GUIContent("Lit & Shade Mixing Multiplier", "Texture (R) * Rate. Compatible with UTS2 ShadingGradeMap. White is Default. Black amplifies shade."), _shadingGradeTexture, _shadingGradeRate); } EditorGUILayout.Space(); EditorGUILayout.LabelField("Light Color", EditorStyles.boldLabel); { materialEditor.ShaderProperty(_lightColorAttenuation, "LightColor Attenuation"); materialEditor.ShaderProperty(_indirectLightIntensity, "GI Intensity"); } EditorGUILayout.Space(); EditorGUILayout.LabelField("Emission", EditorStyles.boldLabel); { materialEditor.TexturePropertySingleLine(new GUIContent("Emission", "Emission (RGB)"), _emissionMap, _emissionColor); materialEditor.TexturePropertySingleLine(new GUIContent("MatCap", "MatCap Texture (RGB)"), _sphereAdd); } EditorGUILayout.Space(); EditorGUILayout.LabelField("Normal", EditorStyles.boldLabel); { // Normal EditorGUI.BeginChangeCheck(); materialEditor.TexturePropertySingleLine(new GUIContent("Normal Map", "Normal Map (RGB)"), _bumpMap, _bumpScale); if (EditorGUI.EndChangeCheck()) { materialEditor.RegisterPropertyChangeUndo("BumpEnabledDisabled"); ModeChanged(materials); } } } EditorGUILayout.EndVertical(); EditorGUILayout.Space(); EditorGUILayout.LabelField("Outline", EditorStyles.boldLabel); EditorGUILayout.BeginVertical(GUI.skin.box); { // Outline EditorGUILayout.LabelField("Width", EditorStyles.boldLabel); { if (PopupEnum <OutlineWidthMode>("Mode", _outlineWidthMode, materialEditor)) { ModeChanged(materials); } var widthMode = (OutlineWidthMode)_outlineWidthMode.floatValue; if (widthMode != OutlineWidthMode.None) { materialEditor.TexturePropertySingleLine( new GUIContent("Width", "Outline Width Texture (RGB)"), _outlineWidthTexture, _outlineWidth); } if (widthMode == OutlineWidthMode.ScreenCoordinates) { materialEditor.ShaderProperty(_outlineScaledMaxDistance, "Width Scaled Max Distance"); } } EditorGUILayout.Space(); EditorGUILayout.LabelField("Color", EditorStyles.boldLabel); { var widthMode = (OutlineWidthMode)_outlineWidthMode.floatValue; if (widthMode != OutlineWidthMode.None) { EditorGUI.BeginChangeCheck(); if (PopupEnum <OutlineColorMode>("Mode", _outlineColorMode, materialEditor)) { ModeChanged(materials); } var colorMode = (OutlineColorMode)_outlineColorMode.floatValue; materialEditor.ShaderProperty(_outlineColor, "Color"); if (colorMode == OutlineColorMode.MixedLighting) { materialEditor.DefaultShaderProperty(_outlineLightingMix, "Lighting Mix"); } } } } EditorGUILayout.EndVertical(); EditorGUILayout.Space(); EditorGUILayout.LabelField("Options", EditorStyles.boldLabel); EditorGUILayout.BeginVertical(GUI.skin.box); { EditorGUILayout.LabelField("Texture Options", EditorStyles.boldLabel); { EditorGUI.BeginChangeCheck(); materialEditor.TextureScaleOffsetProperty(_mainTex); if (EditorGUI.EndChangeCheck()) { foreach (var textureProperty in uvMappedTextureProperties) { textureProperty.textureScaleAndOffset = _mainTex.textureScaleAndOffset; } } } EditorGUILayout.Space(); EditorGUILayout.LabelField("Debugging Options", EditorStyles.boldLabel); { if (PopupEnum <DebugMode>("Visualize", _debugMode, materialEditor)) { ModeChanged(materials); } } EditorGUILayout.Space(); EditorGUILayout.LabelField("Advanced Options", EditorStyles.boldLabel); { #if UNITY_5_6_OR_NEWER // materialEditor.EnableInstancingField(); materialEditor.DoubleSidedGIField(); #endif materialEditor.RenderQueueField(); } } EditorGUILayout.EndVertical(); EditorGUILayout.Space(); } EditorGUI.EndChangeCheck(); }