Exemplo n.º 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/"))
     {
         WallTilingShaderGUI.SetupMaterialWithBlendMode(material, (WallTilingShaderGUI.BlendMode)material.GetFloat("_Mode"));
     }
     else
     {
         WallTilingShaderGUI.BlendMode blendMode = WallTilingShaderGUI.BlendMode.Opaque;
         if (oldShader.name.Contains("/Transparent/Cutout/"))
         {
             blendMode = WallTilingShaderGUI.BlendMode.Cutout;
         }
         else if (oldShader.name.Contains("/Transparent/"))
         {
             blendMode = WallTilingShaderGUI.BlendMode.Fade;
         }
         material.SetFloat("_Mode", (float)blendMode);
         this.DetermineWorkflow(MaterialEditor.GetMaterialProperties(new Material[]
         {
             material
         }));
         WallTilingShaderGUI.MaterialChanged(material, this.m_WorkflowMode);
     }
 }
Exemplo n.º 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)
            {
                WallTilingShaderGUI.MaterialChanged(material, this.m_WorkflowMode);
                this.m_FirstTimeApply = false;
            }
            this.ShaderPropertiesGUI(material);
        }
Exemplo n.º 3
0
        private static void SetMaterialKeywords(Material material, WallTilingShaderGUI.WorkflowMode workflowMode)
        {
            WallTilingShaderGUI.SetKeyword(material, "_NORMALMAP", material.GetTexture("_BumpMap") || material.GetTexture("_DetailNormalMap"));
            if (workflowMode == WallTilingShaderGUI.WorkflowMode.Specular)
            {
                WallTilingShaderGUI.SetKeyword(material, "_SPECGLOSSMAP", material.GetTexture("_SpecGlossMap"));
            }
            else if (workflowMode == WallTilingShaderGUI.WorkflowMode.Metallic)
            {
                WallTilingShaderGUI.SetKeyword(material, "_METALLICGLOSSMAP", material.GetTexture("_MetallicGlossMap"));
            }
            WallTilingShaderGUI.SetKeyword(material, "_PARALLAXMAP", material.GetTexture("_ParallaxMap"));
            WallTilingShaderGUI.SetKeyword(material, "_DETAIL_MULX2", material.GetTexture("_DetailAlbedoMap") || material.GetTexture("_DetailNormalMap"));
            MaterialEditor.FixupEmissiveFlag(material);
            bool state = (material.globalIlluminationFlags & MaterialGlobalIlluminationFlags.EmissiveIsBlack) == MaterialGlobalIlluminationFlags.None;

            WallTilingShaderGUI.SetKeyword(material, "_EMISSION", state);
            if (material.HasProperty("_SmoothnessTextureChannel"))
            {
                WallTilingShaderGUI.SetKeyword(material, "_SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A", WallTilingShaderGUI.GetSmoothnessMapChannel(material) == WallTilingShaderGUI.SmoothnessMapChannel.AlbedoAlpha);
            }
        }
Exemplo n.º 4
0
 private static void MaterialChanged(Material material, WallTilingShaderGUI.WorkflowMode workflowMode)
 {
     WallTilingShaderGUI.SetupMaterialWithBlendMode(material, (WallTilingShaderGUI.BlendMode)material.GetFloat("_Mode"));
     WallTilingShaderGUI.SetMaterialKeywords(material, workflowMode);
 }
Exemplo n.º 5
0
        public void ShaderPropertiesGUI(Material material)
        {
            EditorGUIUtility.labelWidth = 0f;
            bool  enableWallTiling;
            float wallTilingFloat = material.GetFloat("_WallTiling");

            if (wallTilingFloat == 0)
            {
                enableWallTiling = false;
            }
            else
            {
                enableWallTiling = true;
            }

            enableWallTiling = EditorGUILayout.ToggleLeft("Enable Tiling", enableWallTiling);
            if (enableWallTiling)
            {
                //Do tiling scale shader
                float tilingScale = material.GetFloat("_TextureScale");
                tilingScale = EditorGUILayout.Slider("Tile Scale", tilingScale, 0.00001f, 15);
                material.SetFloat("_TextureScale", tilingScale);


                material.SetFloat("_WallTiling", 1);
            }
            else
            {
                material.SetFloat("_WallTiling", 0);
            }

            EditorGUI.BeginChangeCheck();
            this.BlendModePopup();
            GUILayout.Label(WallTilingShaderGUI.Styles.primaryMapsText, EditorStyles.boldLabel, new GUILayoutOption[0]);
            this.DoAlbedoArea(material);
            this.DoSpecularMetallicArea();
            this.m_MaterialEditor.TexturePropertySingleLine(WallTilingShaderGUI.Styles.normalMapText, this.bumpMap, (!(this.bumpMap.textureValue != null)) ? null : this.bumpScale);
            this.m_MaterialEditor.TexturePropertySingleLine(WallTilingShaderGUI.Styles.heightMapText, this.heightMap, (!(this.heightMap.textureValue != null)) ? null : this.heigtMapScale);
            this.m_MaterialEditor.TexturePropertySingleLine(WallTilingShaderGUI.Styles.occlusionText, this.occlusionMap, (!(this.occlusionMap.textureValue != null)) ? null : this.occlusionStrength);
            this.m_MaterialEditor.TexturePropertySingleLine(WallTilingShaderGUI.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(WallTilingShaderGUI.Styles.secondaryMapsText, EditorStyles.boldLabel, new GUILayoutOption[0]);
            this.m_MaterialEditor.TexturePropertySingleLine(WallTilingShaderGUI.Styles.detailAlbedoText, this.detailAlbedoMap);
            this.m_MaterialEditor.TexturePropertySingleLine(WallTilingShaderGUI.Styles.detailNormalMapText, this.detailNormalMap, this.detailNormalMapScale);
            this.m_MaterialEditor.TextureScaleOffsetProperty(this.detailAlbedoMap);
            this.m_MaterialEditor.ShaderProperty(this.uvSetSecondary, WallTilingShaderGUI.Styles.uvSetLabel.text);
            GUILayout.Label(WallTilingShaderGUI.Styles.forwardText, EditorStyles.boldLabel, new GUILayoutOption[0]);
            if (this.highlights != null)
            {
                this.m_MaterialEditor.ShaderProperty(this.highlights, WallTilingShaderGUI.Styles.highlightsText);
            }
            if (this.reflections != null)
            {
                this.m_MaterialEditor.ShaderProperty(this.reflections, WallTilingShaderGUI.Styles.reflectionsText);
            }
            if (EditorGUI.EndChangeCheck())
            {
                UnityEngine.Object[] targets = this.blendMode.targets;
                for (int i = 0; i < targets.Length; i++)
                {
                    UnityEngine.Object @object = targets[i];
                    WallTilingShaderGUI.MaterialChanged((Material)@object, this.m_WorkflowMode);
                }
            }
            EditorGUILayout.Space();
            GUILayout.Label(WallTilingShaderGUI.Styles.advancedText, EditorStyles.boldLabel, new GUILayoutOption[0]);
            this.m_MaterialEditor.EnableInstancingField();
            this.m_MaterialEditor.DoubleSidedGIField();
        }