Ejemplo n.º 1
0
 /// <summary>
 /// Displays fields for secondary color
 /// </summary>
 /// <param name="me"></param>
 protected void ShowSecondaryColor(MaterialEditor me)
 {
     EditorGUILayout.Space();
     MultiMaterialEditorGUI.ColorField(me, "_Color2", "Secondary Color");
     MultiMaterialEditorGUI.Slider(me, "_Color2Strength", "Secondary Color Strength", 0.0f, 1.0f);
     EditorGUILayout.Space();
 }
Ejemplo n.º 2
0
 protected void ShowSurfaceShaderProperties(MaterialEditor me)
 {
     MultiMaterialEditorGUI.TextureField(me, "_SmoothnessMap", "Smoothness (R), Metallic (G)", false);
     MultiMaterialEditorGUI.Slider(me, "_Glossiness", "Smoothness", 0, 1);
     MultiMaterialEditorGUI.Slider(me, "_Metallic", "Metallic", 0, 1);
     MultiMaterialEditorGUI.TextureField(me, "_BumpMap", "Normal Map (RGB)", false);
     MultiMaterialEditorGUI.TextureField(me, "_OcclusionMap", "Occlusion (R)", false);
     MultiMaterialEditorGUI.Slider(me, "_OcclusionStrength", "Occlusion Strength", 0, 1);
     MultiMaterialEditorGUI.ColorField(me, "_EmissionColor", "Emission Color", true, true, true);
     MultiMaterialEditorGUI.TextureField(me, "_EmissionMap", "Emission (RGB)", false);
 }
Ejemplo n.º 3
0
 protected void ShowInsideColor(MaterialEditor me)
 {
     MultiMaterialEditorGUI.ColorField(me, "_InsideColor", "Inside Color");
 }
Ejemplo n.º 4
0
 // ######################## FUNCTIONALITY ######################## //
 protected void ShowGeneralProperties1(MaterialEditor me)
 {
     MultiMaterialEditorGUI.ColorField(me, "_Color", "Color");
     MultiMaterialEditorGUI.TextureField(me, "_MainTex", "Albedo", false);
 }
Ejemplo n.º 5
0
 // ######################## FUNCTIONALITY ######################## //
 /// <summary>
 /// Displays fields for main color and main texture
 /// </summary>
 /// <param name="me"></param>
 protected void ShowColAnMainTex(MaterialEditor me)
 {
     MultiMaterialEditorGUI.ColorField(me, "_Color", "Color");
     MultiMaterialEditorGUI.TextureField(me, "_MainTex", "Albedo (RGBA)", false);
 }
Ejemplo n.º 6
0
    /// <summary>
    /// Shows options for rendering a border around the cutout
    /// </summary>
    /// <param name="me"></param>
    /// <param name="useStencil"></param>
    /// <param name="isSurfaceShader"></param>
    private void ShowBorderOptions(MaterialEditor me, bool useStencil, bool isSurfaceShader)
    {
        GUILayout.Space(30);
        EditorGUILayout.LabelField("Borders", EditorStyles.boldLabel);

        MultiMaterialEditorGUI.TextureField(me, "_BorderTex", "Border Texture", true);

        // get properties for the options that are combined values
        MaterialProperty borderMode       = MaterialEditor.GetMaterialProperty(me.targets, "_BorderMode");
        MaterialProperty useBorderTexture = MaterialEditor.GetMaterialProperty(me.targets, "_UseBorderTexture");
        MaterialProperty borderThresholds = MaterialEditor.GetMaterialProperty(me.targets, "_BorderThresholds");

        bool modeChanged       = false;
        bool useTextureChanged = false;
        bool thresholdsChanged = false;

        // sorting
        EditorGUI.showMixedValue = borderMode.hasMixedValue;
        EditorGUI.BeginChangeCheck();
        int sorting = EditorGUILayout.Popup("Sorting", (int)borderMode.vectorValue.w, new[] { "Border 1 on top", "Border 2 on top" });

        modeChanged = EditorGUI.EndChangeCheck();
        EditorGUI.showMixedValue = false;

        // border1
        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Border 1", EditorStyles.boldLabel);

        // blend mode
        EditorGUI.BeginChangeCheck();
        EditorGUI.showMixedValue = borderMode.hasMixedValue;
        int softBorderBlendMode = EditorGUILayout.Popup("Blend Mode", (int)borderMode.vectorValue.y, new[] { "Alpha Blended", "Additive" });

        modeChanged |= EditorGUI.EndChangeCheck();
        EditorGUI.showMixedValue = false;

        // use texture
        EditorGUI.showMixedValue = useBorderTexture.hasMixedValue;
        EditorGUI.BeginChangeCheck();
        bool useTexture1 = EditorGUILayout.ToggleLeft("Use Texture", useBorderTexture.vectorValue.x > 0);

        useTextureChanged        = EditorGUI.EndChangeCheck();
        EditorGUI.showMixedValue = false;

        MultiMaterialEditorGUI.ColorField(me, "_Border1Color", "Color");

        // thickness
        float border1Threshold = borderThresholds.vectorValue.x;

        if (!useStencil)
        {
            EditorGUI.showMixedValue = borderThresholds.hasMixedValue;
            EditorGUI.BeginChangeCheck();
            border1Threshold         = EditorGUILayout.FloatField("Thickness", borderThresholds.vectorValue.x);
            thresholdsChanged        = EditorGUI.EndChangeCheck();
            EditorGUI.showMixedValue = false;
        }

        // border 2
        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Border 2", EditorStyles.boldLabel);

        // use with emission
        EditorGUI.BeginChangeCheck();
        EditorGUI.showMixedValue = borderMode.hasMixedValue;
        bool hardBorderAsEmission = isSurfaceShader && EditorGUILayout.ToggleLeft("Hard Border As Emission", borderMode.vectorValue.x <= 0);

        // blend mode
        int hardBorderBlendMode = (int)borderMode.vectorValue.z;

        if (!hardBorderAsEmission)
        {
            hardBorderBlendMode = EditorGUILayout.Popup("Hard Border Blend Mode", (int)borderMode.vectorValue.z, new[] { "Alpha Blended", "Additive" });
        }
        modeChanged |= EditorGUI.EndChangeCheck();
        EditorGUI.showMixedValue = false;

        // use texture
        bool useTexture2 = useBorderTexture.vectorValue.y > 0;

        if (!hardBorderAsEmission)
        {
            EditorGUI.showMixedValue = useBorderTexture.hasMixedValue;
            EditorGUI.BeginChangeCheck();
            useTexture2              = EditorGUILayout.ToggleLeft("Use Texture", useBorderTexture.vectorValue.y > 0);
            useTextureChanged       |= EditorGUI.EndChangeCheck();
            EditorGUI.showMixedValue = false;
        }

        MultiMaterialEditorGUI.ColorField(me, "_Border2Color", "Color");

        // thickness
        float border2Threshold = borderThresholds.vectorValue.y;

        if (!useStencil)
        {
            EditorGUI.showMixedValue = borderThresholds.hasMixedValue;
            EditorGUI.BeginChangeCheck();
            border2Threshold         = EditorGUILayout.FloatField("Thickness", borderThresholds.vectorValue.y);
            thresholdsChanged       |= EditorGUI.EndChangeCheck();
            EditorGUI.showMixedValue = false;
        }


        // apply values
        if (modeChanged)
        {
            borderMode.vectorValue = new Vector4(hardBorderAsEmission ? 0 : 1, softBorderBlendMode, hardBorderBlendMode, sorting);
        }

        if (useTextureChanged)
        {
            useBorderTexture.vectorValue = new Vector2(useTexture1 ? 1 : 0, useTexture2 ? 1 : 0);
        }

        if (thresholdsChanged)
        {
            borderThresholds.vectorValue = new Vector2(border1Threshold, border2Threshold);
        }
    }