Unreal MiniTip: Batch process mesh settings with Python
You know how when you import a lot of static meshes and need to change some settings on all of them? There is a property matrix, but unfortunately it does not allow to change some important parameters – like MATERIAL!!!?!!111
Python to the rescue!
Here is a small but useful Python snippet to do just that. It goes through all selected assets in content browser and filters out just Static Meshes. It then sets a specific material in first slot.
Also I wanted to change “Use Full Precision UVs” for all meshes. That and a bunch of other useful parameters can be set with lod build settings.
To run the script, select all your meshes in Content Browser and then go to: Tools -> Execute Python Script (at the bottom) and choose this script file wherever it is saved! Done!
import unreal sm_edit_subsys = unreal.StaticMeshEditorSubsystem() material_asset = unreal.EditorAssetLibrary.load_asset('/Game/Materials/MI_AssMaterial') #find the material we want to apply directly by path selected = unreal.EditorUtilityLibrary.get_selected_assets() for asset in selected: if asset.get_class().get_name() != "StaticMesh": continue #skip everything else except static meshes if material_asset is not None: asset.set_material(0, material_asset) #set material to slot 0 sm_build_settings = unreal.MeshBuildSettings(use_mikk_t_space=True, recompute_normals=False, recompute_tangents=True, compute_weighted_normals=True, build_reversed_index_buffer=True, use_full_precision_u_vs=True, generate_lightmap_u_vs=True, remove_degenerates=False) sm_edit_subsys.set_lod_build_settings(asset, 0, sm_build_settings) #set lod0 build settings