unreal.UsdAssetCache
¶
- class unreal.UsdAssetCache(outer: Object | None = None, name: Name | str = 'None')¶
Bases:
Object
Owns the assets generated and reused by USD Stages, allowing thread-safe retrieval/storage.
C++ Source:
Plugin: USDImporter
Module: USDClasses
File: USDAssetCache2.h
Editor Properties: (see get_editor_property/set_editor_property)
asset_storage
(Map[str, Object]): [Read-Only] Main hash to asset storage for all assets that we’re currently using and shouldn’t be GC’dpersistent_asset_storage_size_mb
(double): [Read-Write] This limit specifies how much size is allocated to storing all persistent assets (i.e. assets that will be saved to disk, even if unused by any stage). Set this to 0 to disable persistent asset storage. This has no effect on temporary asset caches (e.g. the ones automatically generated when opening a stage without an asset cache asset assigned)unreferenced_asset_storage_size_mb
(double): [Read-Write] The asset cache will always retain all currently used assets. In addition to that, this limit specifies how much size is allocated to storing assets that remain only for the current session and that aren’t being used by any stage. Set this to 0 to disable storing unreferenced assets.
- add_asset_reference(asset, referencer) bool ¶
Adds a new UObject referencer to a particular asset, returning true if the operation succeeded.
Assets will not be evicted or removed from the cache while the referencer is registered. Note that internally the cache keeps FObjectKey structs constructed from the referencers, instead of direct pointers to them.
- cache_asset(hash, asset, referencer=None) None ¶
Adds an asset to the cache attached to a particular hash, and optionally registering a referencer
- can_remove_asset(hash) bool ¶
Returns true if the asset with the given hash can be removed from the cache. It will return false in case the asset is still being used, either by another consumer asset or directly by some referencer.
- get_all_asset_hashes() Array[str] ¶
Returns all asset hashes tracked by the asset cache, for all storage types. This includes unloaded persistent assets
- get_all_cached_asset_paths() Array[str] ¶
Returns all asset paths tracked by the asset cache, for all storage types. (e.g. “/Game/MyTextures/RedBrick.RedBrick”). This includes unloaded persistent assets
- get_all_loaded_assets() Array[Object] ¶
Returns all assets that are currently loaded in the asset cache. This will not include persistent assets that haven’t been loaded yet.
- get_cached_asset(hash) Object ¶
Returns an asset associated with a particular Hash. If the asset is persistent, unloaded and the “USD.OnDemandCachedAssetLoading” cvar is true, this may cause the asset to be read from the asset cache’s file on disk.
- get_hash_for_asset(asset) str ¶
Returns the hash associated with an asset, in case we own it. Returns the empty string otherwise. Note: This has O(1) time complexity.
- get_num_assets() int32 ¶
Returns how many assets are tracked by the asset cache in total (summing up persistent, referenced and unreferenced storage)
- Return type:
int32
- is_asset_owned_by_cache(asset_path) bool ¶
Returns true in case the asset at AssetPath is tracked by the cache in any way (persistent asset, unreferenced or referenced). An example AssetPath would be “/Game/MyTextures/RedBrick.RedBrick”.
- property persistent_asset_storage_size_mb: float¶
[Read-Write] This limit specifies how much size is allocated to storing all persistent assets (i.e. assets that will be saved to disk, even if unused by any stage). Set this to 0 to disable persistent asset storage. This has no effect on temporary asset caches (e.g. the ones automatically generated when opening a stage without an asset cache asset assigned)
- Type:
(double)
- refresh_storage() None ¶
Updates which assets belong to each storage type. You must call this in case you perform direct operations on the asset cache, after those operations are fully complete.
- remove_all_asset_references(referencer) bool ¶
Removes the particular referencer to all assets tracked by the cache, if it was a referencer to any of them. Returns true if at least one asset referencer count was altered by this.
- remove_asset(hash) Object ¶
If an asset is associated with Hash, it will be returned and the asset cache will stop tracking this asset entirely. Returns nullptr otherwise. See CanRemoveAsset.
WARNING: The asset will still be outer’d to the asset cache, however. The caller is in charge of properly placing the asset at a new Outer object.
- remove_asset_reference(asset, referencer=None) bool ¶
Removes an UObject referencer from a particular asset, returning true if the operation succeeded. If no specific Referencer is provided, all referencers to Asset will be removed.
- touch_asset(asset, referencer=None) bool ¶
Marks the provided asset as being used at this point, optionally adding a specific referencer. This is useful because the asset cache will always prioritize retaining the most recently used assets
- property unreferenced_asset_storage_size_mb: float¶
[Read-Write] The asset cache will always retain all currently used assets. In addition to that, this limit specifies how much size is allocated to storing assets that remain only for the current session and that aren’t being used by any stage. Set this to 0 to disable storing unreferenced assets.
- Type:
(double)