From 59d2e73fac584af41e795721a1d8714225006a31 Mon Sep 17 00:00:00 2001 From: Ryan Inch Date: Tue, 27 Aug 2024 18:00:43 -0400 Subject: [PATCH] Add Blender 4.2+ support for the import/export settings panels. The glTF add-on changed how it handles drawing the user extension settings panels for the import/export dialogs. Now the glTF add-on searches for a single draw method (which handles both import and export) in the __init__.py file of the Hubs add-on where previously it provided a panel for the importer and exporter respectively that we could hook into. This commit adds support for the new method while preserving support for the previous method. --- addons/io_hubs_addon/__init__.py | 22 ++++++++++++++++++++++ addons/io_hubs_addon/io/gltf_exporter.py | 5 ++++- addons/io_hubs_addon/io/gltf_importer.py | 5 ++++- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/addons/io_hubs_addon/__init__.py b/addons/io_hubs_addon/__init__.py index 9856066a..3083b469 100644 --- a/addons/io_hubs_addon/__init__.py +++ b/addons/io_hubs_addon/__init__.py @@ -24,6 +24,28 @@ create_prefs_dir() +# Blender 4.2+ glTF Extension Import/Export Settings Panel +def draw(context, layout): + layout_header, layout_body = layout.panel('HBA_PT_Import_Export_Panel', default_closed=True) + sfile = context.space_data + operator = sfile.active_operator + + # Panel Header + if operator.bl_idname == "EXPORT_SCENE_OT_gltf": + props = bpy.context.scene.HubsComponentsExtensionProperties + elif operator.bl_idname == "IMPORT_SCENE_OT_gltf": + props = bpy.context.scene.HubsComponentsExtensionImportProperties + + layout_header.use_property_split = False + layout_header.prop(props, 'enabled', text="") + layout_header.label(text="Hubs Components") + + # Panel Body + if layout_body: + if operator.bl_idname == "EXPORT_SCENE_OT_gltf": + gltf_exporter.HubsGLTFExportPanel.draw_body(context, layout_body) + elif operator.bl_idname == "IMPORT_SCENE_OT_gltf": + gltf_importer.HubsGLTFImportPanel.draw_body(context, layout_body) def register(): icons.register() diff --git a/addons/io_hubs_addon/io/gltf_exporter.py b/addons/io_hubs_addon/io/gltf_exporter.py index 930fc79e..7b678c1a 100644 --- a/addons/io_hubs_addon/io/gltf_exporter.py +++ b/addons/io_hubs_addon/io/gltf_exporter.py @@ -249,7 +249,10 @@ def draw_header(self, context): self.layout.prop(props, 'enabled', text="") def draw(self, context): - layout = self.layout + self.draw_body(context, self.layout) + + @staticmethod + def draw_body(context, layout): layout.use_property_split = True layout.use_property_decorate = False # No animation. diff --git a/addons/io_hubs_addon/io/gltf_importer.py b/addons/io_hubs_addon/io/gltf_importer.py index 088d0ac8..e0318f39 100644 --- a/addons/io_hubs_addon/io/gltf_importer.py +++ b/addons/io_hubs_addon/io/gltf_importer.py @@ -298,7 +298,10 @@ def draw_header(self, context): self.layout.prop(props, 'enabled', text="") def draw(self, context): - layout = self.layout + self.draw_body(context, self.layout) + + @staticmethod + def draw_body(context, layout): layout.use_property_split = True layout.use_property_decorate = False # No animation.