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


        EditorGUI.BeginChangeCheck();
        RaymarchAlgorithm = (RaymarchType)EditorGUILayout.EnumPopup("Marching to use", RaymarchAlgorithm);
        DebugType         = (DebugRender)EditorGUILayout.EnumPopup("Debug?", DebugType);
        if (EditorGUI.EndChangeCheck())
        {
            var names = Enum.GetNames(typeof(RaymarchType));
            foreach (var name in names)
            {
                if (name.Equals(RaymarchAlgorithm.ToString()))
                {
                    targetMat.EnableKeyword(name);
                }
                else
                {
                    targetMat.DisableKeyword(name);
                }
            }
            names = Enum.GetNames(typeof(DebugRender));

            foreach (var name in names)
            {
                if (name.Equals(DebugType.ToString()))
                {
                    targetMat.EnableKeyword(name);
                }
                else
                {
                    targetMat.DisableKeyword(name);
                }
            }
        }
        base.OnGUI(materialEditor, properties);
    }