Download

Mesh Merging discards materials, but only

Hi,

I am trying to automate merging actors with Python.
My script works when it is called from the editor, but running it with the python script commandlet results in all the materials being discarded and replaced with WorldGridMaterial.
I know this question has been asked here before, but it was never answered. That’s why I’m trying my luck here.

My merge options are the following:

#Set all the merge options
merge_options = EditorScriptingMergeStaticMeshActorsOptions()
merge_options.base_package_name = "/Game/Content/MergedActors/MergedTestActor"
merge_options.destroy_source_actors = False
merge_options.new_actor_label = "MergedTestActor"
merge_options.spawn_merged_actor = True
merge_options.mesh_merging_settings.bake_vertex_data_to_mesh = False
merge_options.mesh_merging_settings.computed_light_map_resolution = False
merge_options.mesh_merging_settings.generate_light_map_uv = False
merge_options.mesh_merging_settings.lod_selection_type = MeshLODSelectionType.ALL_LO_DS
merge_options.mesh_merging_settings.merge_physics_data = True
merge_options.mesh_merging_settings.pivot_point_at_zero = True

# merge meshes actors and retrieve spawned actor
merged_actor = EditorLevelLibrary.merge_static_mesh_actors(actors_to_merge, merge_options)

This merges all the geometries just as expected but the resulting actor only contains one material (the WorldGridMaterial) instead of holding all the different materials of the source meshes, when run with the python script commandlet.

Does anyone know what I have to do to make the python script commandlet do the same thing as runnning the script from the Editor? I really don’t want to open the graphical editor everytime I run this script.

Thank you all for your help!