UE4 Python 修改Instance Material

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)

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值