From 17dcb3fbf5f6c029969cd0a258b199f925120e5f Mon Sep 17 00:00:00 2001 From: BleuRaven Date: Thu, 14 Nov 2024 23:44:23 +0100 Subject: [PATCH] - Fixed: UI Script produce scripts errors when object is not select. - Fixed: UI is hiddend when bfu_export_type is not "export_recursive". --- ReleaseLogs/Version_4.3.9.md | 4 +- .../bfu_addon_parts/bfu_panel_object.py | 4 +- .../bfu_adv_object/bfu_adv_obj_ui.py | 3 - .../bfu_anim_action/bfu_anim_action_ui.py | 6 +- .../bfu_anim_nla/bfu_anim_nla_ui.py | 3 +- .../bfu_assets_references/bfu_asset_ref_ui.py | 8 +- .../bfu_base_object/bfu_base_obj_ui.py | 3 - .../bfu_collision/bfu_collision_ui.py | 4 +- .../bfu_light_map/bfu_light_map_ui.py | 2 +- .../bfu_material/bfu_material_ui.py | 42 +++++---- .../bfu_modular_skeletal_mesh_ui.py | 3 +- .../bfu_skeletal_mesh/bfu_skeletal_mesh_ui.py | 2 +- .../bfu_vertex_color/bfu_vertex_color_ui.py | 86 ++++++++++--------- 13 files changed, 88 insertions(+), 82 deletions(-) diff --git a/ReleaseLogs/Version_4.3.9.md b/ReleaseLogs/Version_4.3.9.md index eb6b66b..88391b3 100644 --- a/ReleaseLogs/Version_4.3.9.md +++ b/ReleaseLogs/Version_4.3.9.md @@ -6,4 +6,6 @@ Release Logs: https://github.com/xavier150/Blender-For-UnrealEngine-Addons/wiki/ - Changes: Updated fbxio for Blender 4.3. - Fixed: Animation UI not visible on linked Armatures. - Fixed: Generated Builds for Blender 4.1 and olders version is wrong. -- Fixed: Import scripts do not works. (wrong import call in the scripts) \ No newline at end of file +- Fixed: Import scripts do not works. (wrong import call in the scripts) +- Fixed: UI Script produce scripts errors when object is not select. +- Fixed: UI is hiddend when bfu_export_type is not "export_recursive". \ No newline at end of file diff --git a/blender-for-unrealengine/bfu_addon_parts/bfu_panel_object.py b/blender-for-unrealengine/bfu_addon_parts/bfu_panel_object.py index cca99b1..e8266bb 100644 --- a/blender-for-unrealengine/bfu_addon_parts/bfu_panel_object.py +++ b/blender-for-unrealengine/bfu_addon_parts/bfu_panel_object.py @@ -160,8 +160,8 @@ def draw(self, context: bpy.types.Context): bfu_collision.bfu_collision_ui.draw_ui_object(layout, obj) bfu_uv_map.bfu_uv_map_ui.draw_obj_ui(layout, obj) bfu_light_map.bfu_light_map_ui.draw_obj_ui(layout, obj) - bfu_material.bfu_material_ui.draw_ui_object(layout) - bfu_vertex_color.bfu_vertex_color_ui.draw_ui_object(layout) + bfu_material.bfu_material_ui.draw_ui_object(layout, obj) + bfu_vertex_color.bfu_vertex_color_ui.draw_ui_object(layout, obj) bfu_assets_references.bfu_asset_ref_ui.draw_ui(layout, obj) # Animations diff --git a/blender-for-unrealengine/bfu_adv_object/bfu_adv_obj_ui.py b/blender-for-unrealengine/bfu_adv_object/bfu_adv_obj_ui.py index a4e9ad0..2699ab3 100644 --- a/blender-for-unrealengine/bfu_adv_object/bfu_adv_obj_ui.py +++ b/blender-for-unrealengine/bfu_adv_object/bfu_adv_obj_ui.py @@ -32,9 +32,6 @@ def draw_ui(layout: bpy.types.UILayout, obj: bpy.types.Object): - if obj is None: - return - scene = bpy.context.scene addon_prefs = bfu_basics.GetAddonPrefs() diff --git a/blender-for-unrealengine/bfu_anim_action/bfu_anim_action_ui.py b/blender-for-unrealengine/bfu_anim_action/bfu_anim_action_ui.py index 300c85e..a1d1f1a 100644 --- a/blender-for-unrealengine/bfu_anim_action/bfu_anim_action_ui.py +++ b/blender-for-unrealengine/bfu_anim_action/bfu_anim_action_ui.py @@ -31,15 +31,15 @@ def draw_ui(layout: bpy.types.UILayout, obj: bpy.types.Object): scene = bpy.context.scene addon_prefs = bfu_basics.GetAddonPrefs() - is_skeletal_mesh = bfu_skeletal_mesh.bfu_skeletal_mesh_utils.is_skeletal_mesh(obj) - is_camera = bfu_camera.bfu_camera_utils.is_camera(obj) - is_alembic_animation = bfu_alembic_animation.bfu_alembic_animation_utils.is_alembic_animation(obj) # Hide filters if obj is None: return if obj.bfu_export_type != "export_recursive": return + is_skeletal_mesh = bfu_skeletal_mesh.bfu_skeletal_mesh_utils.is_skeletal_mesh(obj) + is_camera = bfu_camera.bfu_camera_utils.is_camera(obj) + is_alembic_animation = bfu_alembic_animation.bfu_alembic_animation_utils.is_alembic_animation(obj) if True not in [is_skeletal_mesh, is_camera, is_alembic_animation]: return diff --git a/blender-for-unrealengine/bfu_anim_nla/bfu_anim_nla_ui.py b/blender-for-unrealengine/bfu_anim_nla/bfu_anim_nla_ui.py index 537cb90..9d29dad 100644 --- a/blender-for-unrealengine/bfu_anim_nla/bfu_anim_nla_ui.py +++ b/blender-for-unrealengine/bfu_anim_nla/bfu_anim_nla_ui.py @@ -30,13 +30,14 @@ def draw_ui(layout: bpy.types.UILayout, obj: bpy.types.Object): scene = bpy.context.scene addon_prefs = bfu_basics.GetAddonPrefs() - is_skeletal_mesh = bfu_skeletal_mesh.bfu_skeletal_mesh_utils.is_skeletal_mesh(obj) + # Hide filters if obj is None: return if obj.bfu_export_type != "export_recursive": return + is_skeletal_mesh = bfu_skeletal_mesh.bfu_skeletal_mesh_utils.is_skeletal_mesh(obj) if bfu_ui.bfu_ui_utils.DisplayPropertyFilter("OBJECT", "ANIM"): scene.bfu_animation_nla_properties_expanded.draw(layout) diff --git a/blender-for-unrealengine/bfu_assets_references/bfu_asset_ref_ui.py b/blender-for-unrealengine/bfu_assets_references/bfu_asset_ref_ui.py index 3de1e89..181ec18 100644 --- a/blender-for-unrealengine/bfu_assets_references/bfu_asset_ref_ui.py +++ b/blender-for-unrealengine/bfu_assets_references/bfu_asset_ref_ui.py @@ -26,9 +26,6 @@ def draw_ui(layout: bpy.types.UILayout, obj: bpy.types.Object): - - if obj is None: - return scene = bpy.context.scene addon_prefs = bfu_basics.GetAddonPrefs() @@ -42,7 +39,8 @@ def draw_ui(layout: bpy.types.UILayout, obj: bpy.types.Object): return if obj.bfu_export_type != "export_recursive": return - if bfu_skeletal_mesh.bfu_skeletal_mesh_utils.is_not_skeletal_mesh(obj): + is_skeletal_mesh = bfu_skeletal_mesh.bfu_skeletal_mesh_utils.is_skeletal_mesh(obj) + if is_skeletal_mesh is False: return # Draw UI @@ -51,7 +49,7 @@ def draw_ui(layout: bpy.types.UILayout, obj: bpy.types.Object): if scene.bfu_engine_ref_properties_expanded.is_expend(): # SkeletalMesh prop - if bfu_skeletal_mesh.bfu_skeletal_mesh_utils.is_skeletal_mesh(obj): + if is_skeletal_mesh: if not obj.bfu_export_as_lod_mesh: unreal_engine_refs = layout.column() draw_skeleton_prop(unreal_engine_refs, obj) diff --git a/blender-for-unrealengine/bfu_base_object/bfu_base_obj_ui.py b/blender-for-unrealengine/bfu_base_object/bfu_base_obj_ui.py index c74b9d2..8723acc 100644 --- a/blender-for-unrealengine/bfu_base_object/bfu_base_obj_ui.py +++ b/blender-for-unrealengine/bfu_base_object/bfu_base_obj_ui.py @@ -39,9 +39,6 @@ def draw_ui(layout: bpy.types.UILayout, obj: bpy.types.Object): return if bfu_utils.GetExportAsProxy(obj): return - if obj.bfu_export_type != "export_recursive": - return - if bfu_ui.bfu_ui_utils.DisplayPropertyFilter("OBJECT", "GENERAL"): scene.bfu_object_properties_expanded.draw(layout) if scene.bfu_object_properties_expanded.is_expend(): diff --git a/blender-for-unrealengine/bfu_collision/bfu_collision_ui.py b/blender-for-unrealengine/bfu_collision/bfu_collision_ui.py index 6fab13c..38981be 100644 --- a/blender-for-unrealengine/bfu_collision/bfu_collision_ui.py +++ b/blender-for-unrealengine/bfu_collision/bfu_collision_ui.py @@ -29,12 +29,12 @@ def draw_ui_object(layout: bpy.types.UILayout, obj: bpy.types.Object): scene = bpy.context.scene addon_prefs = bfu_basics.GetAddonPrefs() - is_static_mesh = bfu_static_mesh.bfu_static_mesh_utils.is_static_mesh(obj) - is_skeletal_mesh = bfu_skeletal_mesh.bfu_skeletal_mesh_utils.is_skeletal_mesh(obj) # Hide filters if obj is None: return + is_static_mesh = bfu_static_mesh.bfu_static_mesh_utils.is_static_mesh(obj) + is_skeletal_mesh = bfu_skeletal_mesh.bfu_skeletal_mesh_utils.is_skeletal_mesh(obj) if addon_prefs.useGeneratedScripts is False: return if bfu_utils.GetExportAsProxy(obj): diff --git a/blender-for-unrealengine/bfu_light_map/bfu_light_map_ui.py b/blender-for-unrealengine/bfu_light_map/bfu_light_map_ui.py index 18b1c67..7c76b44 100644 --- a/blender-for-unrealengine/bfu_light_map/bfu_light_map_ui.py +++ b/blender-for-unrealengine/bfu_light_map/bfu_light_map_ui.py @@ -30,11 +30,11 @@ def draw_obj_ui(layout: bpy.types.UILayout, obj: bpy.types.Object): scene = bpy.context.scene addon_prefs = bfu_basics.GetAddonPrefs() - is_static_mesh = bfu_static_mesh.bfu_static_mesh_utils.is_static_mesh(obj) # Hide filters if obj is None: return + is_static_mesh = bfu_static_mesh.bfu_static_mesh_utils.is_static_mesh(obj) if addon_prefs.useGeneratedScripts is False: return if bfu_utils.GetExportAsProxy(obj): diff --git a/blender-for-unrealengine/bfu_material/bfu_material_ui.py b/blender-for-unrealengine/bfu_material/bfu_material_ui.py index 01dedd3..83a2d93 100644 --- a/blender-for-unrealengine/bfu_material/bfu_material_ui.py +++ b/blender-for-unrealengine/bfu_material/bfu_material_ui.py @@ -27,27 +27,33 @@ -def draw_ui_object(layout: bpy.types.UILayout): - if bfu_ui.bfu_ui_utils.DisplayPropertyFilter("OBJECT", "MISC"): +def draw_ui_object(layout: bpy.types.UILayout, obj: bpy.types.Object): + + scene = bpy.context.scene + addon_prefs = bfu_basics.GetAddonPrefs() + + # Hide filters + if obj is None: + return + if addon_prefs.useGeneratedScripts is False: + return + if obj.bfu_export_type != "export_recursive": + return + if obj.bfu_export_as_lod_mesh: + return - scene = bpy.context.scene + if bfu_ui.bfu_ui_utils.DisplayPropertyFilter("OBJECT", "MISC"): scene.bfu_object_material_properties_expanded.draw(layout) if scene.bfu_object_material_properties_expanded.is_expend(): - - addon_prefs = bfu_basics.GetAddonPrefs() - obj = bpy.context.object - if addon_prefs.useGeneratedScripts and obj is not None: - if obj.bfu_export_type == "export_recursive": - if not obj.bfu_export_as_lod_mesh: - asset_class = bfu_assets_manager.bfu_asset_manager_utils.get_asset_class(obj) - if asset_class and asset_class.use_materials == True: - bfu_material_search_location = layout.column() - bbpl.blender_layout.layout_doc_button.add_doc_page_operator(bfu_material_search_location, text="About Materials", url="https://github.com/xavier150/Blender-For-UnrealEngine-Addons/wiki/Material") - bfu_material_search_location.prop(obj, 'bfu_material_search_location') - bfu_material_search_location.prop(obj, 'bfu_import_materials') - bfu_material_search_location.prop(obj, 'bfu_import_textures') - bfu_material_search_location.prop(obj, 'bfu_flip_normal_map_green_channel') - bfu_material_search_location.prop(obj, 'bfu_reorder_material_to_fbx_order') + asset_class = bfu_assets_manager.bfu_asset_manager_utils.get_asset_class(obj) + if asset_class and asset_class.use_materials == True: + bfu_material_search_location = layout.column() + bbpl.blender_layout.layout_doc_button.add_doc_page_operator(bfu_material_search_location, text="About Materials", url="https://github.com/xavier150/Blender-For-UnrealEngine-Addons/wiki/Material") + bfu_material_search_location.prop(obj, 'bfu_material_search_location') + bfu_material_search_location.prop(obj, 'bfu_import_materials') + bfu_material_search_location.prop(obj, 'bfu_import_textures') + bfu_material_search_location.prop(obj, 'bfu_flip_normal_map_green_channel') + bfu_material_search_location.prop(obj, 'bfu_reorder_material_to_fbx_order') def draw_ui_scene_collision(layout: bpy.types.UILayout): diff --git a/blender-for-unrealengine/bfu_modular_skeletal_mesh/bfu_modular_skeletal_mesh_ui.py b/blender-for-unrealengine/bfu_modular_skeletal_mesh/bfu_modular_skeletal_mesh_ui.py index d791b5c..cb03971 100644 --- a/blender-for-unrealengine/bfu_modular_skeletal_mesh/bfu_modular_skeletal_mesh_ui.py +++ b/blender-for-unrealengine/bfu_modular_skeletal_mesh/bfu_modular_skeletal_mesh_ui.py @@ -45,13 +45,12 @@ def draw_ui_object(layout: bpy.types.UILayout, obj: bpy.types.Object): scene = bpy.context.scene addon_prefs = bfu_basics.GetAddonPrefs() - is_skeletal_mesh = bfu_skeletal_mesh.bfu_skeletal_mesh_utils.is_skeletal_mesh(obj) - if obj is None: return if obj.type != "ARMATURE": return + is_skeletal_mesh = bfu_skeletal_mesh.bfu_skeletal_mesh_utils.is_skeletal_mesh(obj) if is_skeletal_mesh is False: return if obj.bfu_export_type != "export_recursive": diff --git a/blender-for-unrealengine/bfu_skeletal_mesh/bfu_skeletal_mesh_ui.py b/blender-for-unrealengine/bfu_skeletal_mesh/bfu_skeletal_mesh_ui.py index 8102f39..7ea55f5 100644 --- a/blender-for-unrealengine/bfu_skeletal_mesh/bfu_skeletal_mesh_ui.py +++ b/blender-for-unrealengine/bfu_skeletal_mesh/bfu_skeletal_mesh_ui.py @@ -47,10 +47,10 @@ def draw_ui_object(layout: bpy.types.UILayout, obj: bpy.types.Object): scene = bpy.context.scene addon_prefs = bfu_basics.GetAddonPrefs() - is_skeletal_mesh = bfu_skeletal_mesh_utils.is_skeletal_mesh(obj) if obj is None: return + is_skeletal_mesh = bfu_skeletal_mesh_utils.is_skeletal_mesh(obj) if obj.type != "ARMATURE": return if is_skeletal_mesh is False: diff --git a/blender-for-unrealengine/bfu_vertex_color/bfu_vertex_color_ui.py b/blender-for-unrealengine/bfu_vertex_color/bfu_vertex_color_ui.py index e0e04a4..f42537a 100644 --- a/blender-for-unrealengine/bfu_vertex_color/bfu_vertex_color_ui.py +++ b/blender-for-unrealengine/bfu_vertex_color/bfu_vertex_color_ui.py @@ -26,51 +26,57 @@ -def draw_ui_object(layout: bpy.types.UILayout): +def draw_ui_object(layout: bpy.types.UILayout, obj: bpy.types.Object): + + scene = bpy.context.scene + addon_prefs = bfu_basics.GetAddonPrefs() + + # Hide filters + if obj is None: + return + if addon_prefs.useGeneratedScripts is False: + return + if obj.bfu_export_type != "export_recursive": + return + if obj.bfu_export_as_lod_mesh: + return + if bfu_ui.bfu_ui_utils.DisplayPropertyFilter("OBJECT", "MISC"): - scene = bpy.context.scene scene.bfu_object_vertex_color_properties_expanded.draw(layout) if scene.bfu_object_vertex_color_properties_expanded.is_expend(): + # Vertex color + bfu_vertex_color_settings = layout.column() + bbpl.blender_layout.layout_doc_button.add_doc_page_operator(bfu_vertex_color_settings, text="About Vertex Color", url="https://github.com/xavier150/Blender-For-UnrealEngine-Addons/wiki/Vertex-Color") + bfu_vertex_color_settings.prop(obj, 'bfu_vertex_color_import_option') + if obj.bfu_vertex_color_import_option == "OVERRIDE": + bfu_vertex_color_settings_color = bfu_vertex_color_settings.row() + bfu_vertex_color_settings_color.prop(obj, 'bfu_vertex_color_override_color') + + if obj.bfu_vertex_color_import_option == "REPLACE": + StaticMeshVertexColorImportOptionIndex = bfu_vertex_color_settings.row() + StaticMeshVertexColorImportOptionIndex.prop(obj, 'bfu_vertex_color_to_use') + if obj.bfu_vertex_color_to_use == "CustomIndex": + StaticMeshVertexColorImportOptionIndexCustom = bfu_vertex_color_settings.row() + StaticMeshVertexColorImportOptionIndexCustom.prop(obj, 'bfu_vertex_color_index_to_use') - addon_prefs = bfu_basics.GetAddonPrefs() - obj = bpy.context.object - if addon_prefs.useGeneratedScripts and obj is not None: - if obj.bfu_export_type == "export_recursive": - if not obj.bfu_export_as_lod_mesh: - - # Vertex color - bfu_vertex_color_settings = layout.column() - bbpl.blender_layout.layout_doc_button.add_doc_page_operator(bfu_vertex_color_settings, text="About Vertex Color", url="https://github.com/xavier150/Blender-For-UnrealEngine-Addons/wiki/Vertex-Color") - bfu_vertex_color_settings.prop(obj, 'bfu_vertex_color_import_option') - if obj.bfu_vertex_color_import_option == "OVERRIDE": - bfu_vertex_color_settings_color = bfu_vertex_color_settings.row() - bfu_vertex_color_settings_color.prop(obj, 'bfu_vertex_color_override_color') - - if obj.bfu_vertex_color_import_option == "REPLACE": - StaticMeshVertexColorImportOptionIndex = bfu_vertex_color_settings.row() - StaticMeshVertexColorImportOptionIndex.prop(obj, 'bfu_vertex_color_to_use') - if obj.bfu_vertex_color_to_use == "CustomIndex": - StaticMeshVertexColorImportOptionIndexCustom = bfu_vertex_color_settings.row() - StaticMeshVertexColorImportOptionIndexCustom.prop(obj, 'bfu_vertex_color_index_to_use') - - StaticMeshVertexColorFeedback = bfu_vertex_color_settings.row() - if obj.type == "MESH": - vced = bfu_vertex_color_utils.VertexColorExportData(obj) - if vced.export_type == "REPLACE": - my_text = f'Vertex color named {vced.name} will be used.' - StaticMeshVertexColorFeedback.label(text=my_text, icon='INFO') - else: - my_text = 'No vertex color found at this index.' - StaticMeshVertexColorFeedback.label(text=my_text, icon='ERROR') - else: - my_text = 'Vertex color property will be applied on the children.' - StaticMeshVertexColorFeedback.label(text=my_text, icon='INFO') - - # Add 'colors_type' parameter if Blender version is 3.4 or above - blender_version = bpy.app.version - if blender_version >= (3, 4, 0): - bfu_vertex_color_settings.prop(obj, 'bfu_vertex_color_type') + StaticMeshVertexColorFeedback = bfu_vertex_color_settings.row() + if obj.type == "MESH": + vced = bfu_vertex_color_utils.VertexColorExportData(obj) + if vced.export_type == "REPLACE": + my_text = f'Vertex color named {vced.name} will be used.' + StaticMeshVertexColorFeedback.label(text=my_text, icon='INFO') + else: + my_text = 'No vertex color found at this index.' + StaticMeshVertexColorFeedback.label(text=my_text, icon='ERROR') + else: + my_text = 'Vertex color property will be applied on the children.' + StaticMeshVertexColorFeedback.label(text=my_text, icon='INFO') + + # Add 'colors_type' parameter if Blender version is 3.4 or above + blender_version = bpy.app.version + if blender_version >= (3, 4, 0): + bfu_vertex_color_settings.prop(obj, 'bfu_vertex_color_type') def draw_ui_scene_collision(layout: bpy.types.UILayout):