public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
    {
        FindProperties(props); // MaterialProperties can be animated so we do not cache them but fetch them every event to ensure animated values are updated correctly
        m_MaterialEditor = materialEditor;
        Material material = materialEditor.target as Material;

        // Make sure that needed setup (ie keywords/renderqueue) are set up if we're switching some existing
        // material to a standard shader.
        // Do this before any GUI code has been issued to prevent layout issues in subsequent GUILayout statements (case 780071)
        if (m_FirstTimeApply)
        {
            MaterialChanged(material);
            m_FirstTimeApply = false;

            if (material.HasProperty("_SmoothnessMapChannelGUI"))
            {
                smoothnessMapChannelGUI = (SmoothnessMapChannel)material.GetInt("_SmoothnessMapChannelGUI");
            }
            else
            {
                smoothnessMapChannelGUI = SmoothnessMapChannel.MetallicAlpha;
            }
        }

        ShaderPropertiesGUI(material);
    }
    void DoSpecularMetallicArea(Material material)
    {
        bool hasGlossMap = false;


        hasGlossMap = metallicMap.textureValue != null;
        m_MaterialEditor.TexturePropertySingleLine(Styles.metallicMapText, metallicMap, hasGlossMap ? null : metallic);


        bool showSmoothnessScale = hasGlossMap;

        if (smoothnessMapChannel != null)
        {
            int smoothnessChannel = (int)smoothnessMapChannel.floatValue;
            if (smoothnessChannel == (int)SmoothnessMapChannel.AlbedoAlpha)
            {
                showSmoothnessScale = true;
            }
        }

        int indentation = 2; // align with labels of texture properties

        m_MaterialEditor.ShaderProperty(showSmoothnessScale ? smoothnessScale : smoothness, showSmoothnessScale ? Styles.smoothnessScaleText : Styles.smoothnessText, indentation);

        ++indentation;


        //miner12.23
        GUILayout.BeginHorizontal();
        GUILayout.Label("", GUILayout.Width(27));
        //GUILayout.Label("Source",GUILayout.Width(153));
        smoothnessMapChannelGUI = (SmoothnessMapChannel)EditorGUILayout.EnumPopup("Source", smoothnessMapChannelGUI, GUILayout.ExpandWidth(true));

        if (smoothnessMapChannelGUI == SmoothnessMapChannel.AlbedoAlpha)
        {
            material.EnableKeyword("SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA");
        }
        else
        {
            material.DisableKeyword("SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA");
        }
        material.SetInt("_SmoothnessMapChannelGUI", (int)smoothnessMapChannelGUI);
        GUILayout.EndHorizontal();

        //if (smoothnessMapChannel != null)
        //    m_MaterialEditor.ShaderProperty(smoothnessMapChannel, Styles.smoothnessMapChannelText, indentation);
    }
Example #3
0
    public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
    {
        FindProperties(props);
        m_MaterialEditor = materialEditor;
        Material material = materialEditor.target as Material;

        if (m_FirstTimeApply)
        {
            MaterialChanged(material);
            m_FirstTimeApply = false;
            if (material.HasProperty("_SmoothnessMapChannelGUI"))
            {
                smoothnessMapChannelGUI = (SmoothnessMapChannel)material.GetInt("_SmoothnessMapChannelGUI");
            }
        }
        ShaderPropertiesGUI(material);
    }
Example #4
0
 public static void SetSmoothnessMapChannel(Material material, SmoothnessMapChannel channel)
 {
     material.SetFloat("_SmoothnessTextureChannel", (int)channel);
 }