diff --git a/index.html b/index.html index 85775fc..fe8ba79 100644 --- a/index.html +++ b/index.html @@ -25,10 +25,10 @@ ~ 4.2.0 - ~ all - 16.5KB + 16.7KB -

Built 2024-08-06, 11:30

+

Built 2024-08-06, 22:51

diff --git a/index.json b/index.json index 1fe0df0..f63ed46 100644 --- a/index.json +++ b/index.json @@ -18,8 +18,8 @@ "Object" ], "archive_url": "./unity_exporter.zip", - "archive_size": 16892, - "archive_hash": "sha256:379ff50e4e45fefc3afc0908d546f141b91e6b80ff55d01d5126b8fb5d826900" + "archive_size": 17092, + "archive_hash": "sha256:fb84fde6a1c66a9c712560710ab1e2f831988faecf85061959112817154398c9" } ] } \ No newline at end of file diff --git a/unity_exporter.zip b/unity_exporter.zip index a985aa1..9e439ad 100644 Binary files a/unity_exporter.zip and b/unity_exporter.zip differ diff --git a/unity_exporter/unity_exporter_panel.py b/unity_exporter/unity_exporter_panel.py index 3554270..46ed264 100644 --- a/unity_exporter/unity_exporter_panel.py +++ b/unity_exporter/unity_exporter_panel.py @@ -33,10 +33,12 @@ def draw(self, context): scene = context.scene layout = self.layout layout.prop(scene, "directory_path") - + + layout.operator("unity_exporter.create_folder") row = layout.row() row.operator("unity_exporter.clean_image_names") row.operator("unity_exporter.clean_mesh_names") + layout.operator("unity_exporter.export_images") layout.operator("unity_exporter.export_selected") @@ -116,6 +118,34 @@ def execute(self, context): self.report({'INFO'}, 'Images exported successfully.') return {'FINISHED'} + +class UnityExporterCreateFolder(bpy.types.Operator): + bl_idname = "unity_exporter.create_folder" + bl_label = "Create Folder" + bl_description = "Create a folder in the specified directory" + + def execute(self, context): + # Create a new folder with the same name as the blender file in the directory_path, then set the directory_path to that new folder + blend_file_name = bpy.path.basename(bpy.data.filepath) + directory_path = bpy.context.scene.directory_path + + if not directory_path: + self.report({'WARNING'}, 'Please specify a directory path.') + return {'CANCELLED'} + + if not os.path.exists(directory_path): + self.report({'WARNING'}, 'The specified directory path does not exist.') + return {'CANCELLED'} + + new_directory_path = os.path.join(directory_path, blend_file_name) + try: + os.makedirs(new_directory_path) + bpy.context.scene.directory_path = new_directory_path + self.report({'INFO'}, f"Created folder: {new_directory_path}") + except Exception as e: + self.report({'ERROR'}, f"Failed to create folder: {str(e)}") + return {'CANCELLED'} + return {'FINISHED'} class UnityExporterExportSelected(bpy.types.Operator): bl_idname = "unity_exporter.export_selected" @@ -170,6 +200,7 @@ def execute(self, context): def register(): print("Registering unity_exporter_panel") bpy.utils.register_class(UnityExporterPanel) + bpy.utils.register_class(UnityExporterCreateFolder) bpy.utils.register_class(UnityExporterCleanMeshNames) bpy.utils.register_class(UnityExporterCleanImageNames) bpy.utils.register_class(UnityExporterExportImages) @@ -185,6 +216,7 @@ def register(): def unregister(): bpy.utils.unregister_class(UnityExporterPanel) + bpy.utils.unregister_class(UnityExporterCreateFolder) bpy.utils.unregister_class(UnityExporterCleanMeshNames) bpy.utils.unregister_class(UnityExporterCleanImageNames) bpy.utils.unregister_class(UnityExporterExportImages)