I want to run an automated rename process for assets in an Unreal engine 4 project using Python, however, I only want to rename the Static Meshes, and then the Materials separately, leaving the blueprints alone.
I have looked through the Python API documentation but can't seem to find a function that cycles through the assets and creates a list for each object type. So far I have a function that retrieves all the assets in the contents folder, and puts them in a list. I want a list for each of the object types
asset_names = unreal.EditorAssetLibrary.list_assets(asset_location)
but what I want is something more like
staticmesh_names = unreal.PythonFunction.list_objects(asset_location, StaticMesh)
material_names = unreal.PythonFunction.list_objects(asset_location, Material)
Thanks in advance for the help
static_mesh_data = unreal.AssetRegistryHelpers.get_asset_registry().get_assets_by_class("StaticMesh")
static_mesh_objects = [data.get_asset() for data in static_mesh_data]
The returned objects should have a .rename() function
If you're going to use Paulo Scardine's function, you can use this to easily filter out the class type you want:
unreal.EditorFilterLibrary.by_class(loaded_assets, unreal.StaticMesh)