diff --git a/Content/Python/auto_import_pipeline.py b/Content/Python/auto_import_pipeline.py index b2fb4dc..fc35066 100644 --- a/Content/Python/auto_import_pipeline.py +++ b/Content/Python/auto_import_pipeline.py @@ -63,16 +63,21 @@ def import_fbx(filename, name, dest_path): def assign_material(skeletal_mesh, material): + existing_slots = skeletal_mesh.get_editor_property("materials") new_slots = [] - for slot in skeletal_mesh.get_editor_property("materials"): + for slot in existing_slots: new_slot = unreal.SkeletalMaterial() new_slot.set_editor_property("material_interface", material) new_slot.set_editor_property("material_slot_name", slot.get_editor_property("material_slot_name")) - new_slot.set_editor_property("uv_channel_data", slot.get_editor_property("uv_channel_data")) new_slots.append(new_slot) - skeletal_mesh.set_editor_property("materials", new_slots) + if not new_slots: + # FBX had no material assigned to the mesh, so no slot was created on import. + fallback = unreal.SkeletalMaterial() + fallback.set_editor_property("material_interface", material) + fallback.set_editor_property("material_slot_name", "Material") + new_slots.append(fallback) skeletal_mesh.modify() - skeletal_mesh.post_edit_change() + skeletal_mesh.set_editor_property("materials", new_slots) unreal.EditorAssetLibrary.save_asset(skeletal_mesh.get_path_name()) @@ -107,12 +112,17 @@ for asset_folder in os.listdir(DEMO_ROOT): unreal.MaterialInstanceConstantFactoryNew()) mel.set_material_instance_parent(mi, master) + textures = {} for suffix, (param, _, _) in PARAMS.items(): if suffix not in files: continue texture = import_task(os.path.join(src_dir, files[suffix]), f"T_{base_name}{suffix}", dest_path) + textures[suffix] = texture mel.set_material_instance_texture_parameter_value(mi, param, texture) + if "_E" not in files and "_BC" in textures: + mel.set_material_instance_texture_parameter_value(mi, "Emissive", textures["_BC"]) + unreal.EditorAssetLibrary.save_asset(mi.get_path_name()) assign_material(mesh, mi) asset_count += 1 diff --git a/DemoAssets/pilot/CC3_Base_Plus_Bake_N.jpeg b/DemoAssets/pilot/CC3_Base_Plus_Bake_N.jpeg deleted file mode 100644 index b386e55..0000000 Binary files a/DemoAssets/pilot/CC3_Base_Plus_Bake_N.jpeg and /dev/null differ