Пример #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/"))
     {
         StandardRoughnessShaderGUI.SetupMaterialWithBlendMode(material, (StandardRoughnessShaderGUI.BlendMode)material.GetFloat("_Mode"));
     }
     else
     {
         StandardRoughnessShaderGUI.BlendMode blendMode = StandardRoughnessShaderGUI.BlendMode.Opaque;
         if (oldShader.name.Contains("/Transparent/Cutout/"))
         {
             blendMode = StandardRoughnessShaderGUI.BlendMode.Cutout;
         }
         else if (oldShader.name.Contains("/Transparent/"))
         {
             blendMode = StandardRoughnessShaderGUI.BlendMode.Fade;
         }
         material.SetFloat("_Mode", (float)blendMode);
         StandardRoughnessShaderGUI.MaterialChanged(material);
     }
 }
Пример #2
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)
            {
                StandardRoughnessShaderGUI.MaterialChanged(material);
                this.m_FirstTimeApply = false;
            }
            this.ShaderPropertiesGUI(material);
        }
Пример #3
0
 public void ShaderPropertiesGUI(Material material)
 {
     EditorGUIUtility.labelWidth = 0f;
     EditorGUI.BeginChangeCheck();
     this.BlendModePopup();
     GUILayout.Label(StandardRoughnessShaderGUI.Styles.primaryMapsText, EditorStyles.boldLabel, new GUILayoutOption[0]);
     this.DoAlbedoArea(material);
     this.m_MaterialEditor.TexturePropertySingleLine(StandardRoughnessShaderGUI.Styles.metallicMapText, this.metallicMap, (!(this.metallicMap.textureValue != null)) ? this.metallic : null);
     this.m_MaterialEditor.TexturePropertySingleLine(StandardRoughnessShaderGUI.Styles.roughnessText, this.roughnessMap, (!(this.roughnessMap.textureValue != null)) ? this.roughness : null);
     this.m_MaterialEditor.TexturePropertySingleLine(StandardRoughnessShaderGUI.Styles.normalMapText, this.bumpMap, (!(this.bumpMap.textureValue != null)) ? null : this.bumpScale);
     this.m_MaterialEditor.TexturePropertySingleLine(StandardRoughnessShaderGUI.Styles.heightMapText, this.heightMap, (!(this.heightMap.textureValue != null)) ? null : this.heigtMapScale);
     this.m_MaterialEditor.TexturePropertySingleLine(StandardRoughnessShaderGUI.Styles.occlusionText, this.occlusionMap, (!(this.occlusionMap.textureValue != null)) ? null : this.occlusionStrength);
     this.m_MaterialEditor.TexturePropertySingleLine(StandardRoughnessShaderGUI.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(StandardRoughnessShaderGUI.Styles.secondaryMapsText, EditorStyles.boldLabel, new GUILayoutOption[0]);
     this.m_MaterialEditor.TexturePropertySingleLine(StandardRoughnessShaderGUI.Styles.detailAlbedoText, this.detailAlbedoMap);
     this.m_MaterialEditor.TexturePropertySingleLine(StandardRoughnessShaderGUI.Styles.detailNormalMapText, this.detailNormalMap, this.detailNormalMapScale);
     this.m_MaterialEditor.TextureScaleOffsetProperty(this.detailAlbedoMap);
     this.m_MaterialEditor.ShaderProperty(this.uvSetSecondary, StandardRoughnessShaderGUI.Styles.uvSetLabel.text);
     GUILayout.Label(StandardRoughnessShaderGUI.Styles.forwardText, EditorStyles.boldLabel, new GUILayoutOption[0]);
     if (this.highlights != null)
     {
         this.m_MaterialEditor.ShaderProperty(this.highlights, StandardRoughnessShaderGUI.Styles.highlightsText);
     }
     if (this.reflections != null)
     {
         this.m_MaterialEditor.ShaderProperty(this.reflections, StandardRoughnessShaderGUI.Styles.reflectionsText);
     }
     if (EditorGUI.EndChangeCheck())
     {
         UnityEngine.Object[] targets = this.blendMode.targets;
         for (int i = 0; i < targets.Length; i++)
         {
             UnityEngine.Object @object = targets[i];
             StandardRoughnessShaderGUI.MaterialChanged((Material)@object);
         }
     }
     EditorGUILayout.Space();
     GUILayout.Label(StandardRoughnessShaderGUI.Styles.advancedText, EditorStyles.boldLabel, new GUILayoutOption[0]);
     this.m_MaterialEditor.EnableInstancingField();
     this.m_MaterialEditor.DoubleSidedGIField();
 }