unreal.EditorAssetSubsystem

class unreal.EditorAssetSubsystem(outer: Optional[Object] = None, name: Union[Name, str] = 'None')

Bases: EditorSubsystem

UEditorAssetSubsystem Subsystem for exposing asset related utilities to scripts. Asset Paths can be represented in the following ways:

(Reference/Text Path) StaticMesh’/Game/MyFolder/MyAsset.MyAsset’ (Full Name) StaticMesh /Game/MyFolder/MyAsset.MyAsset (Path Name) /Game/MyFolder/MyAsset.MyAsset (Package Name) /Game/MyFolder/MyAsset

Directory Paths can be represented in the following ways:

/Game/MyNewFolder/ /Game/MyNewFolder

C++ Source:

  • Module: UnrealEd

  • File: EditorAssetSubsystem.h

add_on_extract_asset_from_file(delegate) None

Call this to add a callback to extract an asset from a file, for example from a drag and drop operation.

Parameters:

delegate (OnExtractAssetFromFileDynamic) –

checkout_asset(asset_to_checkout) bool

Checkout an asset.

Parameters:

asset_to_checkout (str) – Asset Path of the asset that we want to checkout.

Returns:

True if the operation succeeds.

Return type:

bool

checkout_directory(directory_path, recursive=True) bool

Checkout all assets in a directory. It will load the assets if needed. All objects that are in the directory will be checked out. Assets will be loaded before being checked out.

Parameters:
  • directory_path (str) – Directory of the assets to be checked out.

  • recursive (bool) – If the AssetPath is a folder, the search will be recursive and will checkout the assets in the sub folders.

Returns:

True if the operation succeeds.

Return type:

bool

checkout_loaded_asset(asset_to_checkout) bool

Checkout the asset corresponding to an object.

Parameters:

asset_to_checkout (Object) – Asset to checkout.

Returns:

True if the operation succeeds.

Return type:

bool

checkout_loaded_assets(assets_to_checkout) bool

Checkout the assets.

Parameters:

assets_to_checkout (Array[Object]) – Assets to checkout.

Returns:

True if the operation succeeds.

Return type:

bool

consolidate_assets(asset_to_consolidate_to, assets_to_consolidate) bool

Consolidates assets by replacing all references/uses of the provided AssetsToConsolidate with references to AssetToConsolidateTo. This is useful when you want all references of assets to be replaced by a single asset. The function first attempts to directly replace all relevant references located within objects that are already loaded and in memory. Next, it deletes the AssetsToConsolidate, leaving behind object redirectors to AssetToConsolidateTo. note: The AssetsToConsolidate are DELETED by this function. note: Modified objects will be saved if the operation succeeds.

Parameters:
  • asset_to_consolidate_to (Object) – Asset to which all references of the AssetsToConsolidate will instead refer to after this operation completes.

  • assets_to_consolidate (Array[Object]) – All references to these assets will be modified to reference AssetToConsolidateTo instead.

Returns:

True if the operation succeeds.

Return type:

bool

delete_asset(asset_path_to_delete) bool

Delete the package an asset is in. All objects in the package will be deleted. This is a Force Delete. It does not check if the asset has references in other Levels or by Actors. It will close all the asset editors and may clear the Transaction buffer (Undo History). Will try to mark the file as deleted. The Asset will be loaded before being deleted.

Parameters:

asset_path_to_delete (str) – Asset Path of the asset to delete.

Returns:

True if the operation succeeds.

Return type:

bool

delete_directory(directory_path) bool

Delete the packages inside a directory. If the directory is then empty, delete the directory. This is a Force Delete. It does not check if the assets have references in other Levels or by Actors. It will close all the asset editors and may clear the Transaction buffer (Undo History). Will try to mark the file as deleted. Assets will be loaded before being deleted. The search is always recursive. It will try to delete the sub folders.

Parameters:

directory_path (str) – Directory that will be marked for deletion and deleted.

Returns:

True if the operation succeeds.

Return type:

bool

delete_loaded_asset(asset_to_delete) bool

Delete an asset that is already loaded. This is a Force Delete. It does not check if the asset has references in other Levels or by Actors. It will close all the asset editors and may clear the Transaction buffer (Undo History). Will try to mark the file as deleted.

Parameters:

asset_to_delete (Object) – Asset to delete.

Returns:

True if the operation succeeds.

Return type:

bool

delete_loaded_assets(assets_to_delete) bool

Delete assets that are already loaded. This is a Force Delete. It does not check if the assets have references in other Levels or by Actors. It will close all the asset editors and may clear the Transaction buffer (Undo History). Will try to mark the files as deleted.

Parameters:

assets_to_delete (Array[Object]) – Loaded assets to delete.

Returns:

True if the operation succeeds.

Return type:

bool

do_assets_exist(asset_paths) bool

Check if assets exist in the Asset Registry.

Parameters:

asset_paths (Array[str]) – Asset Paths of the assets to check for existence.

Returns:

True if all assets exist and are valid.

Return type:

bool

does_asset_exist(asset_path) bool

Check if an asset exists in the Asset Registry.

Parameters:

asset_path (str) – Asset Path to check for existence.

Returns:

True if the asset exists and is valid.

Return type:

bool

does_directory_contain_assets(directory_path, recursive=True) bool

Check if a directory contains any assets.

Parameters:
  • directory_path (str) – Long Path Name of the directory.

  • recursive (bool) –

Returns:

True if there is any assets.

Return type:

bool

does_directory_exist(directory_path) bool

Check if a directory exists.

Parameters:

directory_path (str) – Long Path Name of the directory.

Returns:

True if it does exist and it is valid.

Return type:

bool

duplicate_asset(source_asset_path, destination_asset_path) Object

Duplicate an asset. Will try to checkout the file. The Asset will be loaded before being duplicated.

Parameters:
  • source_asset_path (str) – Asset Path of the asset that we want to copy from.

  • destination_asset_path (str) – Asset Path of the duplicated asset.

Returns:

The duplicated object if the operation succeeds.

Return type:

Object

duplicate_directory(source_directory_path, destination_directory_path) bool

Duplicate a directory and the assets in it. Will try to checkout the files. The Assets will be loaded before being duplicated.

Parameters:
  • source_directory_path (str) – Directory of the assets that we want to duplicate from.

  • destination_directory_path (str) – Directory of the duplicated asset.

Returns:

The duplicated object if the operation succeeds.

Return type:

bool

duplicate_loaded_asset(source_asset, destination_asset_path) Object

Duplicate an asset that is already loaded. Will try to checkout the file.

Parameters:
  • source_asset (Object) – Asset that we want to copy from.

  • destination_asset_path (str) – Asset Path of the duplicated asset.

Returns:

The duplicated object if the operation succeeds

Return type:

Object

find_asset_data(asset_path) AssetData

Return the AssetData for the Asset that can then be used with AssetRegistryHelpers.

Parameters:

asset_path (str) – Asset Path to retrieve data from.

Returns:

The AssetData found.

Return type:

AssetData

find_package_referencers_for_asset(asset_path, load_assets_to_confirm=False) Array[str]

Find Package Referencers for an asset. Only Soft and Hard dependencies will be looked for. Soft are dependencies which don’t need to be loaded for the object to be used. Hard are dependencies which are required for correct usage of the source asset and must be loaded at the same time. Other references may exist. The asset may be currently used in memory by another asset, by the editor or by code. Package dependencies are cached with the asset. False positives can happen until all the assets are loaded and re-saved.

Parameters:
  • asset_path (str) – Asset Path of the asset that we are looking for.

  • load_assets_to_confirm (bool) – Whether the asset and any potential referencers will be loaded to confirm the dependencies.

Returns:

The package paths of the referencers.

Return type:

Array[str]

get_metadata_tag(object, tag) str

Get the value associated with the given tag of a loaded asset’s metadata.

Parameters:
  • object (Object) – The object from which to retrieve the metadata.

  • tag (Name) – The tag to find in the metadata.

Returns:

The string value associated with the tag.

Return type:

str

get_metadata_tag_values(object) Map[Name, str]

Get all tags/values of a loaded asset’s metadata.

Parameters:

object (Object) – The object from which to retrieve the metadata.

Returns:

The list of all Tags and Values.

Return type:

Map[Name, str]

get_path_name_for_loaded_asset(loaded_asset) str

Return a valid AssetPath for a loaded asset. Similar to GetPathName(). The format will be: /Game/MyFolder/MyAsset.MyAsset

Parameters:

loaded_asset (Object) – The loaded asset to get the path of.

Returns:

If valid, the asset Path of the loaded asset.

Return type:

str

get_tag_values(asset_path) Map[Name, str]

Gets all TagValues (from Asset Registry) associated with an (unloaded) asset as strings value.

Parameters:

asset_path (str) – Asset Path we are trying to find.

Returns:

The list of all TagNames & TagValues.

Return type:

Map[Name, str]

list_assets(directory_path, recursive=True, include_folder=False) Array[str]

Return the list of all the assets found in the DirectoryPath.

Parameters:
  • directory_path (str) – Directory path of the asset we want the list from.

  • recursive (bool) – The search will be recursive and will look in sub folders.

  • include_folder (bool) – The result will include folders name.

Returns:

The list of assets found.

Return type:

Array[str]

list_assets_by_tag_value(tag_name, tag_value) Array[str]

Return the list of all the assets that have the pair of Tag/Value.

Parameters:
  • tag_name (Name) – The tag associated with the assets requested.

  • tag_value (str) – The value associated with the assets requested.

Returns:

The list of assets found.

Return type:

Array[str]

load_asset(asset_path) Object

Load an asset. It will verify if the object is already loaded and only load it if it’s necessary.

Parameters:

asset_path (str) – Asset Path of the asset to load

Returns:

Found or loaded asset.

Return type:

Object

load_blueprint_class(asset_path)

Load a Blueprint asset and return its generated class. It will verify if the object is already loaded and only load it if it’s necessary.

Parameters:

asset_path (str) – Asset Path of the Blueprint asset.

Returns:

Found or loaded class.

Return type:

type(Class)

make_directory(directory_path) bool

Create a directory on disk.

Parameters:

directory_path (str) – Long Path Name of the directory.

Returns:

True if the operation succeeds.

Return type:

bool

remove_metadata_tag(object, tag) None

Remove the given tag from a loaded asset’s metadata.

Parameters:
  • object (Object) – The object from which to retrieve the metadata.

  • tag (Name) – The tag to remove from the metadata.

remove_on_extract_asset_from_file(delegate) None

Call this to remove a callback added with AddOnExtractAssetFromFile.

Parameters:

delegate (OnExtractAssetFromFileDynamic) –

rename_asset(source_asset_path, destination_asset_path) bool

Rename an asset. Equivalent to a Move operation. Will try to checkout the file. The Asset will be loaded before being renamed.

Parameters:
  • source_asset_path (str) – Asset Path of the asset that we want to copy from.

  • destination_asset_path (str) – Asset Path of the renamed asset.

Returns:

True if the operation succeeds.

Return type:

bool

rename_directory(source_directory_path, destination_directory_path) bool

Rename a directory. Equivalent to a Move operation moving all contained assets. Will try to checkout the files. The Assets will be loaded before being renamed.

Parameters:
  • source_directory_path (str) – Directory of the assets that we want to rename from.

  • destination_directory_path (str) – Directory of the renamed asset.

Returns:

True if the operation succeeds.

Return type:

bool

rename_loaded_asset(source_asset, destination_asset_path) bool

Rename an asset that is already loaded. Equivalent to a Move operation. Will try to checkout the file.

Parameters:
  • source_asset (Object) – Asset that we want to copy from.

  • destination_asset_path (str) – Asset Path of the duplicated asset.

Returns:

True if the operation succeeds.

Return type:

bool

save_asset(asset_to_save, only_if_is_dirty=True) bool

Save the packages the assets live in. All objects that live in the package will be saved. Will try to checkout the file first. The Asset will be loaded before being saved.

Parameters:
  • asset_to_save (str) – Asset Path of the asset that we want to save.

  • only_if_is_dirty (bool) – Only checkout/save the asset if it’s dirty.

Returns:

True if the operation succeeds.

Return type:

bool

save_directory(directory_path, only_if_is_dirty=True, recursive=True) bool

Save the packages the assets live in inside the directory. All objects that are in the directory will be saved. Will try to checkout the file first. Assets will be loaded before being saved.

Parameters:
  • directory_path (str) – Directory that will be checked out and saved.

  • only_if_is_dirty (bool) – Only checkout asset that are dirty.

  • recursive (bool) – The search will be recursive and it will save the asset in the sub folders.

Returns:

True if the operation succeeds.

Return type:

bool

save_loaded_asset(asset_to_save, only_if_is_dirty=True) bool

Save the package the asset lives in. All objects that live in the package will be saved. Will try to checkout the file.

Parameters:
  • asset_to_save (Object) – Asset that we want to save.

  • only_if_is_dirty (bool) – Only checkout asset that are dirty.

Returns:

True if the operation succeeds.

Return type:

bool

save_loaded_assets(assets_to_save, only_if_is_dirty=True) bool

Save the packages the assets live in. All objects that live in the packages will be saved. Will try to checkout the files.

Parameters:
  • assets_to_save (Array[Object]) – Assets that we want to save.

  • only_if_is_dirty (bool) – Only checkout asset that are dirty.

Returns:

True if the operation succeeds.

Return type:

bool

set_metadata_tag(object, tag, value) None

Set the value associated with a given tag of a loaded asset’s metadata.

Parameters:
  • object (Object) – The object from which to retrieve the metadata.

  • tag (Name) – The tag to set in the metadata.

  • value (str) – The string value to associate with the tag.