Hi,
I am trying to automate merging actors with Python.
When I use “Merge Actors” within the Editor everything works as expected, but when I use Python all materials get discarded and WorldGridMaterial gets set as the material for the whole merged mesh.
I used this paper (page 26) as a reference for merging actors with Python.
First I get all the actors that I want to merge like this (Note: When this code is run only the desired meshes are loaded in the level):
# Get all the actors
actors = EditorLevelLibrary.get_all_level_actors()
actors_to_merge = [a for a in actors if a.__class__ == StaticMeshActor]
All the StaticMeshActors
in actors_to_merge
still have all materials at this point.
Then I use the following code to merge the actors:
#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 instead of holding all the different materials of the source meshes.
Does anyone know what I have to do to make Python do the same thing as the Editor? Thank you all for your help!