def change_instance_material_property(is_two_side, material_object):
assets = assetRegistry.get_assets_by_package_name(material_object.get_name())
for asset in assets:
mat_instance = unreal.MaterialInstance.cast(asset.get_asset())
if mat_instance:
aa = unreal.MaterialInstanceBasePropertyOverrides()
aa.set_editor_property('override_two_sided', is_two_side)
aa.set_editor_property('two_sided', is_two_side)
mat_instance.set_editor_property('base_property_overrides',aa)
unreal.EditorAssetLibrary.save_loaded_asset(asset.get_asset())
def change_actor_material_side(label, is_two_side):
all_actors = unreal.EditorLevelLibrary.get_all_level_actors()
for actor in all_actors:
actor_name = actor.get_name()
if '_INSTid1238_' in actor_name:
class_name = actor.static_class().get_name()
if class_name == 'Actor':
print(actor_name)
for i in range(0,actor.root_component.get_num_children_components()):
com = actor.root_component.get_child_component(i)
material_object = com.get_material(0).get_outer()
change_instance_material_property(is_two_side, material_object)
if class_name == 'StaticMeshActor':
material_object = actor.root_component.get_material(0).get_outer()
change_instance_material_property(is_two_side, material_object)
print('start')
change_actor_material_side('1238', True)
|