Download

Script example of mass changes to assets?

Just getting started on scripting. Any examples out there of changing asset parameters via scripting? What I want to do:

  • iterate through every static mesh in the project
  • change LOD setting based on largest mesh XYZ approx size parameter
  • save mesh with new settings

I have a class that goes through selected textures in the content browser and changes the type to VT and saves the asset, you can start from here



import unreal

def register():
    assets = unreal.EditorUtilityLibrary.get_selected_asset_data()
    try:
        for asset in assets:
            object_path = unreal.StructBase.get_editor_property(asset , 'object_path')
            package_name = str(unreal.StructBase.get_editor_property(asset , 'package_name'))
            package_path = unreal.StructBase.get_editor_property(asset , 'package_path')
            asset_name = str(unreal.StructBase.get_editor_property(asset , 'asset_name'))
            asset_class = unreal.StructBase.get_editor_property(asset , 'asset_class')
            if (asset_class == 'Texture2D'):
                tmp_asset = unreal.load_asset(object_path)
                tmp_asset.set_editor_property("virtual_texture_streaming", True)
                unreal.EditorAssetLibrary.save_asset(object_path, True)
    except Exception as error:
        print(error)


Awesome thanks. :cool: