コード例 #1
0
    public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
    {
        Material material = materialEditor.target as Material;

        m_MaterialEditor = materialEditor;

        FindMaterialProperties(properties);

        EditorGUI.BeginChangeCheck();
        DoBlendMode();

        EditorGUILayout.Space();
        DoSpecular();

        EditorGUILayout.Space();
        m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, bumpMapProp);

        EditorGUILayout.Space();
        m_MaterialEditor.TexturePropertySingleLine(Styles.emissionMapLabel, emissionMapProp, emissionColorProp);

        EditorGUILayout.Space();
        DoReflection();

        if (EditorGUI.EndChangeCheck())
        {
            LegacyBlinnPhongUpgrader.UpdateMaterialKeywords(material);
        }

        EditorGUILayout.Space();
        EditorGUILayout.Space();

        materialEditor.RenderQueueField();

        EditorGUILayout.Space();
        EditorGUILayout.Space();

        if ((UpgradeBlendMode)blendModeProp.floatValue == UpgradeBlendMode.Cutout)
        {
            Styles.warningStyle.normal.textColor = Color.yellow;
            EditorGUILayout.LabelField(Styles.alphaCutoutWarning, Styles.warningStyle);
        }
    }
    public override void AssignNewShaderToMaterial(Material material, Shader oldShader, Shader newShader)
    {
        base.AssignNewShaderToMaterial(material, oldShader, newShader);

        // Shininess value cannot be zero since it will produce undefined values for cases where pow(0, 0).
        float shininess = material.GetFloat("_Shininess");

        material.SetFloat("_Shininess", Mathf.Clamp(shininess, kMinShininessValue, 1.0f));

        string oldShaderName = oldShader.name;

        string[] shaderStrings = oldShaderName.Split('/');

        if (shaderStrings[0].Equals("Legacy Shaders") || shaderStrings[0].Equals("Mobile"))
        {
            ConvertFromLegacy(material, oldShaderName);
        }

        LegacyBlinnPhongUpgrader.UpdateMaterialKeywords(material);
    }
    public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
    {
        Material material = materialEditor.target as Material;

        m_MaterialEditor = materialEditor;

        FindMaterialProperties(properties);

        EditorGUI.BeginChangeCheck();
        {
            DoBlendMode();

            EditorGUILayout.Space();
            DoSpecular();

            EditorGUILayout.Space();
            m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, bumpMapProp);

            EditorGUILayout.Space();
            DoEmissionArea(material);

            EditorGUI.BeginChangeCheck();
            m_MaterialEditor.TextureScaleOffsetProperty(albedoMapProp);
            if (EditorGUI.EndChangeCheck())
            {
                emissionMapProp.textureScaleAndOffset = albedoMapProp.textureScaleAndOffset; // Apply the main texture scale and offset to the emission texture as well, for Enlighten's sake
            }
        }
        if (EditorGUI.EndChangeCheck())
        {
            LegacyBlinnPhongUpgrader.UpdateMaterialKeywords(material);
        }

        EditorGUILayout.Space();
        EditorGUILayout.Space();

        materialEditor.RenderQueueField();

        EditorGUILayout.Space();
        EditorGUILayout.Space();
    }