How to update material on static mesh with a python script?

How do you update the static mesh’s material like you would in the editor? I don’t see in the API docs on where to do this. It doesn’t seem as straight forward as it should be. Below is current implementation.

       import unreal
        
       EAS = unreal.get_editor_subsystem(unreal.EditorActorSubsystem)
       actor_class = unreal.StaticMeshActor
       actor = EAS.spawn_actor_from_class(actor_class, unreal.Vector(), unreal.Rotator())
       mesh = unreal.EditorAssetLibrary.load_asset('/Game/Assets/testAsset.fbx')
       actor.static_mesh_component.set_static_mesh(mesh)

I found out. Further digging into the documentation. StaticMeshComponent extends from PrimitiveComponent and has a set_material() method. :grinning:

I have the problem that materials with duplicated textures are shown blurry. I always need to go into the material editor and then the material is shown as normal and not blurry anymore.
Does anybody know how to trigger this update effect done by the material editor?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.