Esempio n. 1
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hash = 17;
         hash += hash * 23 + Texture.GetHashCode();
         hash += hash * 23 + BlendMode.GetHashCode();
         return(hash);
     }
 }
Esempio n. 2
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hashCode = BlendMode.GetHashCode();
         hashCode = (hashCode * 397) ^ (Shader != null ? Shader.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Texture != null ? Texture.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ DrawLayer;
         return(hashCode);
     }
 }
Esempio n. 3
0
 public override int GetHashCode()
 {
     return(DepthTest.GetHashCode() ^ DepthBias.GetHashCode() ^ FrontFace.GetHashCode() ^ CullMode.GetHashCode() ^ BlendMode.GetHashCode() ^ FillMode.GetHashCode() ^ StencilMode.GetHashCode());
 }
Esempio n. 4
0
    public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
    {
        FindProperties(properties);
        EditorGUI.BeginChangeCheck();

        Material  material = materialEditor.target as Material;
        BlendMode render   = (BlendMode)Enum.ToObject(typeof(BlendMode), Convert.ToInt32(modeBlend.floatValue));

        render = (BlendMode)EditorGUILayout.EnumPopup("Render Mode", (BlendMode)Enum.ToObject(typeof(BlendMode), Convert.ToInt32(modeBlend.floatValue)));
        EditorGUILayout.Space();

        EditorGUILayout.LabelField("Maps And Color", EditorStyles.boldLabel);
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("", GUILayout.MinWidth(105));
        materialEditor.TexturePropertyMiniThumbnail(GUILayoutUtility.GetLastRect(), textureMap, "Albedo", "Albedo (RGB) and Transparency (A)");
        GUILayout.FlexibleSpace();
        EditorGUIUtility.labelWidth = 420;
        EditorGUILayout.LabelField("", GUILayout.MinWidth(60));
        color.colorValue            = materialEditor.ColorProperty(GUILayoutUtility.GetLastRect(), color, "");
        EditorGUIUtility.labelWidth = 0;
        EditorGUILayout.EndHorizontal();
        EditorGUI.indentLevel += 1;
        if (render == BlendMode.Cutout)
        {
            cutoutAlpha.floatValue = EditorGUILayout.Slider("Cutout Alpha", cutoutAlpha.floatValue, 0, 1);
        }
        if (textureMap.textureValue != null)
        {
            GUILayout.Space(20);
            EditorGUILayout.LabelField("");
            materialEditor.TextureScaleOffsetProperty(GUILayoutUtility.GetLastRect(), textureMap);
        }
        EditorGUILayout.Space();
        EditorGUI.indentLevel += -1;

        EditorGUILayout.BeginHorizontal();
        try {
            if (!textureRamp.textureValue)
            {
                throw new UnityException();
            }
            (textureRamp.textureValue as Texture2D).GetPixels();
            EditorGUILayout.LabelField("", GUILayout.MinWidth(105));
            materialEditor.TexturePropertyMiniThumbnail(GUILayoutUtility.GetLastRect(), textureRamp, "Light Ramp", "Albedo (RGB) and Transparency (A)");
            GUILayout.FlexibleSpace();
            EditorGUIUtility.labelWidth = 420;
            EditorGUILayout.LabelField("", GUILayout.MinWidth(60));
            Rect last     = GUILayoutUtility.GetLastRect();
            Rect offset   = new Rect(last.x - 1.4f, last.y - 1.6f, last.width + 2.4f, last.height + 3);
            var  boldtext = new GUIStyle(GUI.skin.textField);
            if (Event.current.type == EventType.Repaint)
            {
                boldtext.Draw(offset, textureRamp.textureValue, false, false, true, false);
            }
            EditorGUI.DrawPreviewTexture(last, textureRamp.textureValue ?
                                         ToGrayscale(textureRamp.textureValue as Texture2D, rampSaturation.floatValue) :
                                         new Texture2D(1, 1, TextureFormat.Alpha8, false));
        } catch (UnityException) {
            EditorGUIUtility.labelWidth = 100;
            EditorGUILayout.LabelField("", GUILayout.MaxWidth(0));
            materialEditor.TexturePropertyMiniThumbnail(GUILayoutUtility.GetLastRect(), textureRamp, "Light Ramp", "Albedo (RGB) and Transparency (A)");
            GUILayout.FlexibleSpace();
            EditorGUILayout.HelpBox("No Preview, texture not readable.", MessageType.None);
        }
        EditorGUIUtility.labelWidth = 0;
        EditorGUILayout.EndHorizontal();
        EditorGUI.indentLevel += 1;
        if (textureRamp.textureValue)
        {
            noLightRamp.floatValue = 0;
            material.EnableKeyword("LIGHTRAMP_ON");
            material.DisableKeyword("LIGHTRAMP_OFF");
        }
        else
        {
            noLightRamp.floatValue = 1;
            material.EnableKeyword("LIGHTRAMP_OFF");
            material.DisableKeyword("LIGHTRAMP_ON");
        }
        // noLightRamp.floatValue = EditorGUILayout.Toggle(noLightRamp.floatValue.Equals(0), GUILayout.MinWidth(60)) ? 1 : 0;
        EditorGUILayout.Space();
        if (textureRamp.textureValue != null)
        {
            rampSaturation.floatValue = EditorGUILayout.Slider("Gray Scale", rampSaturation.floatValue, 0, 1);
            EditorGUILayout.Space();
        }
        EditorGUILayout.BeginHorizontal();
        EditorGUIUtility.labelWidth = 75;
        shadowColor.colorValue      = ColorLuminance(EditorGUILayout.ColorField("Shadow", shadowColor.colorValue));
        highlightColor.colorValue   = ColorLuminance(EditorGUILayout.ColorField("Highlight", highlightColor.colorValue));
        EditorGUIUtility.labelWidth = 0;
        EditorGUILayout.EndHorizontal();
        roughness.floatValue = EditorGUILayout.Slider("Roughness", roughness.floatValue, 0, 1);
        specular.floatValue  = EditorGUILayout.Slider("Specular", specular.floatValue, 0, 1);
        // if (textureRamp.textureValue != null) {
        //  GUILayout.Space(20);
        //  EditorGUILayout.LabelField("");
        //  materialEditor.TextureScaleOffsetProperty(GUILayoutUtility.GetLastRect(), textureRamp);
        // }
        EditorGUILayout.Space();
        EditorGUI.indentLevel += -1;

        modeBlend.floatValue = render.GetHashCode();
        SetMaterialBlendMode(material, render);

        base.OnGUI(materialEditor, properties);
    }