WIP: MaterialX addon #104594
@ -35,10 +35,16 @@ from . import logging
|
||||
log = logging.Log("__init__")
|
||||
|
||||
|
||||
register_classes, unregister_classes = bpy.utils.register_classes_factory([
|
||||
node_tree.MxNodeTree,
|
||||
preferences.AddonPreferences,
|
||||
])
|
||||
|
||||
|
||||
def register():
|
||||
log("register")
|
||||
bpy.utils.register_class(preferences.AddonPreferences)
|
||||
bpy.utils.register_class(node_tree.MxNodeTree)
|
||||
|
||||
register_classes()
|
||||
nodes.register()
|
||||
matlib.register()
|
||||
material.register()
|
||||
@ -46,8 +52,8 @@ def register():
|
||||
|
||||
def unregister():
|
||||
log("unregister")
|
||||
|
||||
material.unregister()
|
||||
matlib.unregister()
|
||||
nodes.unregister()
|
||||
material.unregister()
|
||||
bpy.utils.unregister_class(node_tree.MxNodeTree)
|
||||
bpy.utils.unregister_class(preferences.AddonPreferences)
|
||||
unregister_classes()
|
||||
|
@ -11,6 +11,7 @@ from bpy_extras.io_utils import ImportHelper, ExportHelper
|
||||
|
||||
from ..node_tree import MxNodeTree
|
||||
from .. import utils
|
||||
from ..preferences import addon_preferences
|
||||
|
||||
from ..utils import logging
|
||||
log = logging.Log('nodes.ui')
|
||||
@ -194,9 +195,7 @@ class NODES_PT_dev(bpy.types.Panel):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
# TODO: enable
|
||||
# return config.show_dev_settings
|
||||
return True
|
||||
return addon_preferences().dev_tools
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
@ -3,12 +3,38 @@
|
||||
|
||||
import bpy
|
||||
|
||||
from .utils import with_prefix
|
||||
from . import logging, ADDON_ALIAS
|
||||
|
||||
|
||||
class AddonPreferences(bpy.types.AddonPreferences):
|
||||
bl_idname = with_prefix('AddonPreferences')
|
||||
bl_idname = ADDON_ALIAS
|
||||
|
||||
def update_log_level(self, context):
|
||||
logging.logger.setLevel(self.log_level)
|
||||
|
||||
dev_tools: bpy.props.BoolProperty(
|
||||
name="Developer Tools",
|
||||
description="Enable developer tools",
|
||||
default=False,
|
||||
)
|
||||
log_level: bpy.props.EnumProperty(
|
||||
name="Log Level",
|
||||
description="Select logging level",
|
||||
items=(('DEBUG', "Debug", "Log level DEBUG"),
|
||||
('INFO', "Info", "Log level INFO"),
|
||||
('WARNING', "Warning", "Log level WARN"),
|
||||
('ERROR', "Error", "Log level ERROR"),
|
||||
('CRITICAL', "Critical", "Log level CRITICAL")),
|
||||
default='INFO',
|
||||
update=update_log_level,
|
||||
)
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
layout.label(text="MaterialX addon preferences")
|
||||
col = layout.column()
|
||||
col.prop(self, "dev_tools")
|
||||
col.prop(self, "log_level")
|
||||
|
||||
|
||||
def addon_preferences():
|
||||
return bpy.context.preferences.addons[ADDON_ALIAS].preferences
|
||||
|
@ -16,7 +16,7 @@ log = logging.Log('utils')
|
||||
|
||||
|
||||
ADDON_ROOT_DIR = Path(__file__).parent
|
||||
ADDON_DATA_DIR = Path(bpy.utils.user_resource("SCRIPTS", path=f"addons/{ADDON_ALIAS}", create=True))
|
||||
ADDON_DATA_DIR = Path(bpy.utils.user_resource("SCRIPTS", path=f"addons/{ADDON_ALIAS}_data", create=True))
|
||||
|
||||
MX_LIBS_FOLDER = "libraries"
|
||||
MX_LIBS_DIR = ADDON_ROOT_DIR / MX_LIBS_FOLDER
|
||||
|
Loading…
Reference in New Issue
Block a user