This commit is contained in:
Vysyr committed 2026-09-05 01:10:01 +02:00
1 parent 661d00f73d
commit 6804ebb106
2 files changed
+14 -4

No files matched your search

+14 -4
View File
@@ -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