19 lines
778 B
Python
Executable File
19 lines
778 B
Python
Executable File
import unreal
|
|
|
|
OLD = unreal.load_asset("/Game/ImportedAssets/Trees/SM_tree04.SM_tree04")
|
|
NEW = unreal.load_asset("/Game/ImportedAssets/Trees/SM_tree01.SM_tree01")
|
|
|
|
sub = unreal.get_editor_subsystem(unreal.EditorActorSubsystem)
|
|
actors = sub.get_all_level_actors()
|
|
|
|
old_mesh_count = 0
|
|
|
|
with unreal.ScopedEditorTransaction("Swap meshes"):
|
|
for actor in actors:
|
|
comp = actor.get_component_by_class(unreal.StaticMeshComponent)
|
|
if comp and comp.static_mesh == OLD:
|
|
comp.set_editor_property("static_mesh", NEW)
|
|
# comp.set_static_mesh(NEW) -- tak tez mozna ale undo nie zadziala bo zmiana nie jest robiona przez edytor wiec jej on nie rejestruje
|
|
old_mesh_count += 1
|
|
|
|
unreal.log(f"Swapped {old_mesh_count} meshes") |