MaterialChanged() private static method

private static MaterialChanged ( Material material, WorkflowMode workflowMode ) : void
material UnityEngine.Material
workflowMode WorkflowMode
return void
Example #1
0
 public override void AssignNewShaderToMaterial(Material material, Shader oldShader, Shader newShader)
 {
     if (material.HasProperty("_Emission"))
     {
         material.SetColor("_EmissionColor", material.GetColor("_Emission"));
     }
     base.AssignNewShaderToMaterial(material, oldShader, newShader);
     if (oldShader == null || !oldShader.name.Contains("Legacy Shaders/"))
     {
         StandardShaderGUI.SetupMaterialWithBlendMode(material, (StandardShaderGUI.BlendMode)material.GetFloat("_Mode"));
     }
     else
     {
         StandardShaderGUI.BlendMode blendMode = StandardShaderGUI.BlendMode.Opaque;
         if (oldShader.name.Contains("/Transparent/Cutout/"))
         {
             blendMode = StandardShaderGUI.BlendMode.Cutout;
         }
         else if (oldShader.name.Contains("/Transparent/"))
         {
             blendMode = StandardShaderGUI.BlendMode.Fade;
         }
         material.SetFloat("_Mode", (float)blendMode);
         this.DetermineWorkflow(MaterialEditor.GetMaterialProperties(new Material[]
         {
             material
         }));
         StandardShaderGUI.MaterialChanged(material, this.m_WorkflowMode);
     }
 }
 public void ShaderPropertiesGUI(Material material)
 {
     EditorGUIUtility.labelWidth = 0.0f;
     EditorGUI.BeginChangeCheck();
     this.BlendModePopup();
     GUILayout.Label(StandardShaderGUI.Styles.primaryMapsText, EditorStyles.boldLabel, new GUILayoutOption[0]);
     this.DoAlbedoArea(material);
     this.DoSpecularMetallicArea();
     this.m_MaterialEditor.TexturePropertySingleLine(StandardShaderGUI.Styles.normalMapText, this.bumpMap, !((UnityEngine.Object) this.bumpMap.textureValue != (UnityEngine.Object)null) ? (MaterialProperty)null : this.bumpScale);
     this.m_MaterialEditor.TexturePropertySingleLine(StandardShaderGUI.Styles.heightMapText, this.heightMap, !((UnityEngine.Object) this.heightMap.textureValue != (UnityEngine.Object)null) ? (MaterialProperty)null : this.heigtMapScale);
     this.m_MaterialEditor.TexturePropertySingleLine(StandardShaderGUI.Styles.occlusionText, this.occlusionMap, !((UnityEngine.Object) this.occlusionMap.textureValue != (UnityEngine.Object)null) ? (MaterialProperty)null : this.occlusionStrength);
     this.DoEmissionArea(material);
     this.m_MaterialEditor.TexturePropertySingleLine(StandardShaderGUI.Styles.detailMaskText, this.detailMask);
     EditorGUI.BeginChangeCheck();
     this.m_MaterialEditor.TextureScaleOffsetProperty(this.albedoMap);
     if (EditorGUI.EndChangeCheck())
     {
         this.emissionMap.textureScaleAndOffset = this.albedoMap.textureScaleAndOffset;
     }
     EditorGUILayout.Space();
     GUILayout.Label(StandardShaderGUI.Styles.secondaryMapsText, EditorStyles.boldLabel, new GUILayoutOption[0]);
     this.m_MaterialEditor.TexturePropertySingleLine(StandardShaderGUI.Styles.detailAlbedoText, this.detailAlbedoMap);
     this.m_MaterialEditor.TexturePropertySingleLine(StandardShaderGUI.Styles.detailNormalMapText, this.detailNormalMap, this.detailNormalMapScale);
     this.m_MaterialEditor.TextureScaleOffsetProperty(this.detailAlbedoMap);
     this.m_MaterialEditor.ShaderProperty(this.uvSetSecondary, StandardShaderGUI.Styles.uvSetLabel.text);
     if (!EditorGUI.EndChangeCheck())
     {
         return;
     }
     foreach (Material target in this.blendMode.targets)
     {
         StandardShaderGUI.MaterialChanged(target, this.m_WorkflowMode);
     }
 }
 public override void AssignNewShaderToMaterial(Material material, Shader oldShader, Shader newShader)
 {
     base.AssignNewShaderToMaterial(material, oldShader, newShader);
     if (oldShader == null || !oldShader.name.Contains("Legacy Shaders/"))
     {
         return;
     }
     StandardShaderGUI.BlendMode blendMode = StandardShaderGUI.BlendMode.Opaque;
     if (oldShader.name.Contains("/Transparent/Cutout/"))
     {
         blendMode = StandardShaderGUI.BlendMode.Cutout;
     }
     else
     {
         if (oldShader.name.Contains("/Transparent/"))
         {
             blendMode = StandardShaderGUI.BlendMode.Fade;
         }
     }
     material.SetFloat("_Mode", (float)blendMode);
     this.DetermineWorkflow(ShaderUtil.GetMaterialProperties(new Material[]
     {
         material
     }));
     StandardShaderGUI.MaterialChanged(material, this.m_WorkflowMode);
 }
Example #4
0
        public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
        {
            this.FindProperties(props);
            this.m_MaterialEditor = materialEditor;
            Material material = materialEditor.target as Material;

            if (this.m_FirstTimeApply)
            {
                StandardShaderGUI.MaterialChanged(material, this.m_WorkflowMode);
                this.m_FirstTimeApply = false;
            }
            this.ShaderPropertiesGUI(material);
        }
Example #5
0
 public void ShaderPropertiesGUI(Material material)
 {
     EditorGUIUtility.labelWidth = 0f;
     EditorGUI.BeginChangeCheck();
     this.BlendModePopup();
     GUILayout.Label(StandardShaderGUI.Styles.primaryMapsText, EditorStyles.boldLabel, new GUILayoutOption[0]);
     this.DoAlbedoArea(material);
     this.DoSpecularMetallicArea();
     this.m_MaterialEditor.TexturePropertySingleLine(StandardShaderGUI.Styles.normalMapText, this.bumpMap, (!(this.bumpMap.textureValue != null)) ? null : this.bumpScale);
     this.m_MaterialEditor.TexturePropertySingleLine(StandardShaderGUI.Styles.heightMapText, this.heightMap, (!(this.heightMap.textureValue != null)) ? null : this.heigtMapScale);
     this.m_MaterialEditor.TexturePropertySingleLine(StandardShaderGUI.Styles.occlusionText, this.occlusionMap, (!(this.occlusionMap.textureValue != null)) ? null : this.occlusionStrength);
     this.m_MaterialEditor.TexturePropertySingleLine(StandardShaderGUI.Styles.detailMaskText, this.detailMask);
     this.DoEmissionArea(material);
     EditorGUI.BeginChangeCheck();
     this.m_MaterialEditor.TextureScaleOffsetProperty(this.albedoMap);
     if (EditorGUI.EndChangeCheck())
     {
         this.emissionMap.textureScaleAndOffset = this.albedoMap.textureScaleAndOffset;
     }
     EditorGUILayout.Space();
     GUILayout.Label(StandardShaderGUI.Styles.secondaryMapsText, EditorStyles.boldLabel, new GUILayoutOption[0]);
     this.m_MaterialEditor.TexturePropertySingleLine(StandardShaderGUI.Styles.detailAlbedoText, this.detailAlbedoMap);
     this.m_MaterialEditor.TexturePropertySingleLine(StandardShaderGUI.Styles.detailNormalMapText, this.detailNormalMap, this.detailNormalMapScale);
     this.m_MaterialEditor.TextureScaleOffsetProperty(this.detailAlbedoMap);
     this.m_MaterialEditor.ShaderProperty(this.uvSetSecondary, StandardShaderGUI.Styles.uvSetLabel.text);
     GUILayout.Label(StandardShaderGUI.Styles.forwardText, EditorStyles.boldLabel, new GUILayoutOption[0]);
     if (this.highlights != null)
     {
         this.m_MaterialEditor.ShaderProperty(this.highlights, StandardShaderGUI.Styles.highlightsText);
     }
     if (this.reflections != null)
     {
         this.m_MaterialEditor.ShaderProperty(this.reflections, StandardShaderGUI.Styles.reflectionsText);
     }
     if (EditorGUI.EndChangeCheck())
     {
         UnityEngine.Object[] targets = this.blendMode.targets;
         for (int i = 0; i < targets.Length; i++)
         {
             UnityEngine.Object @object = targets[i];
             StandardShaderGUI.MaterialChanged((Material)@object, this.m_WorkflowMode);
         }
     }
     EditorGUILayout.Space();
     GUILayout.Label(StandardShaderGUI.Styles.advancedText, EditorStyles.boldLabel, new GUILayoutOption[0]);
     this.m_MaterialEditor.RenderQueueField();
     this.m_MaterialEditor.EnableInstancingField();
 }