#if UNITY_EDITOR
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

public class WSMaterialShowDrawer : MaterialPropertyDrawer
{
    protected readonly string keyword;

    public WSMaterialShowDrawer()
    {
    }

    public WSMaterialShowDrawer(string kw)
    {
        keyword = kw;
    }

    public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
    {
        return 0f;
    }

    public override void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor)
    {
        if (string.IsNullOrEmpty(keyword))
        {
            editor.DefaultShaderProperty(prop, label);
            return;
        }
        if (MaterialHasKeyWord(keyword, prop))
        {
            editor.DefaultShaderProperty(prop, label);
        }
    }

    protected bool MaterialHasKeyWord(string kw, MaterialProperty prop)
    {
        foreach(Material mat in prop.targets)
        {
            if (mat.IsKeywordEnabled(kw))
                return true;
        }
        return false;
    }
}
#endif