From 286a34604718eb114ee0c0c6d72aafdaee54f796 Mon Sep 17 00:00:00 2001 From: SimonNordon4 Date: Wed, 7 Aug 2024 08:52:11 +1000 Subject: [PATCH] added create folder to unity exporter. --- index.html | 4 +-- index.json | 4 +-- unity_exporter.zip | Bin 16892 -> 17092 bytes unity_exporter/unity_exporter_panel.py | 34 ++++++++++++++++++++++++- 4 files changed, 37 insertions(+), 5 deletions(-) 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 a985aa14d3253c30740b94c8af45d0d00ccbbd0d..9e439ad926b495b0ecc57d133958a70bf95a9d44 100644 GIT binary patch delta 2161 zcmV-%2#)vsg8{^a0kA6t5^+WcSzmljgzEL8*lD}j-j+5@ao!Jk^ z(tK%tGn$bdt`ja4StQ%@v(Vggncu==cca1xo}8a81z!`Fq(hrHR9kPkc=OmBK41dp zd?F7t4k9Lq;w0iUAZo>bNDvCjd zYX5DK?A&+s|d|`17b3@~L7k=$=fex=vi6s|Ms3^Tho7n_jOq zQ!5^rC+NI{N0H-yNAi-S%bl$jUV^EOh_exwFTR5d(7Ko_GUhQW^G9xhps(JF0mOwP zS+s2A8qqD^C{Pb)xaL=N)Ya?mAnBk7hz)_yAamO7_52zUT$jCHs0I>Wo56sv-;Ank6GxiKnO(mN7@BVc`5VB|N%`VA`j2zriD%~H@m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`Y;FY_VXOh>p*0 zxiN^&Bx>L>vq(p=*dKD;Ja2%m2XhDPy16@n*N3$RJs;-(Zuq^KZozgOj*IU}cPgSg z-C4r_1G7*KLo*Hla|T&t3YzvK2LJ%-9+RO!WCDl`lRX6&lO91i0t6S6p+OUqY(X;u mq8F2)L2CjkDwCl>Ba<;gMgpQelc7N!la@j#25mn80002CXuPEW 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)