Class Content
Loads and manages assets.
Inheritance
Namespace: FlaxEngine
Assembly: FlaxEngine.CSharp.dll
Syntax
[Unmanaged]
public static class Content : Object
Properties
Assets
Gets the assets (loaded or during load).
Declaration
[Unmanaged]
public static Asset[] Assets { get; }
Property Value
Asset[]
|
Stats
Gets content statistics.
Declaration
[Unmanaged]
public static ContentStats Stats { get; }
Property Value
ContentStats
|
Methods
CreateTemporaryAssetPath()
Generates temporary asset path.
Declaration
[Unmanaged]
public static string CreateTemporaryAssetPath()
Returns
System.String
Asset path for a temporary usage. |
CreateVirtualAsset(Type)
Creates temporary and virtual asset of the given type.
Declaration
[Unmanaged]
public static Asset CreateVirtualAsset([TypeReference] Type type)
Parameters
System.Type
type
The asset type klass. |
Returns
Asset
Created asset or null if failed. |
CreateVirtualAsset<T>()
Creates temporary and virtual asset of the given type. Virtual assets have limited usage but allow to use custom assets data at runtime. Virtual assets are temporary and exist until application exit.
Declaration
public static T CreateVirtualAsset<T>()
where T : Asset
Returns
T
Asset instance if created, null otherwise. See log for error message if need to. |
Type Parameters
T
Type of the asset to create. Includes any asset types derived from the type. |
DeleteAsset(Asset)
Deletes the specified asset.
Declaration
[Unmanaged]
public static void DeleteAsset(Asset asset)
Parameters
Asset
asset
The asset. |
GetAllAssets()
Finds all the asset IDs. Uses asset registry.
Declaration
[Unmanaged]
public static Guid[] GetAllAssets()
Returns
System.Guid[]
The list of all asset IDs. |
GetAllAssetsByType(Type)
Finds all the asset IDs by type (exact type, without inheritance checks). Uses asset registry.
Declaration
[Unmanaged]
public static Guid[] GetAllAssetsByType(Type type)
Parameters
System.Type
type
The asset type. |
Returns
System.Guid[]
The list of asset IDs that match the given type. |
GetAsset(Guid)
Finds the asset with given ID. Checks all loaded assets.
Declaration
[Unmanaged]
public static Asset GetAsset(Guid id)
Parameters
System.Guid
id
The id. |
Returns
Asset
The found asset or null if not loaded. |
GetAsset(String)
Finds the asset with at given path. Checks all loaded assets.
Declaration
[Unmanaged]
public static Asset GetAsset(string path)
Parameters
System.String
path
The path. |
Returns
Asset
The found asset or null if not loaded. |
GetAssetInfo(Guid, out AssetInfo)
Finds the asset info by id.
Declaration
[Unmanaged]
public static bool GetAssetInfo(Guid id, out AssetInfo info)
Parameters
System.Guid
id
The asset id. |
AssetInfo
info
The output asset info. Filled with valid values only if method returns true. |
Returns
System.Boolean
True if found any asset, otherwise false. |
GetAssetInfo(String, out AssetInfo)
Finds the asset info by path.
Declaration
[Unmanaged]
public static bool GetAssetInfo(string path, out AssetInfo info)
Parameters
System.String
path
The asset path. |
AssetInfo
info
The output asset info. Filled with valid values only if method returns true. |
Returns
System.Boolean
True if found any asset, otherwise false. |
GetEditorAssetPath(Guid)
Finds the asset path by id. In editor it returns the actual asset path, at runtime it returns the mapped asset path.
Declaration
[Unmanaged]
public static string GetEditorAssetPath(Guid id)
Parameters
System.Guid
id
The asset id. |
Returns
System.String
The asset path, or empty if failed to find. |
Load(Guid, Double)
Loads asset to the Content Pool and holds it until it won't be referenced by any object. Returns null if asset is missing. Actual asset data loading is performed on a other thread in async. The current thread execution is blocked until asset is loaded. Waits until asset will be loaded. It's equivalent to LoadAsync + WaitForLoaded.
Declaration
public static Asset Load(Guid id, double timeoutInMilliseconds = 30000)
Parameters
System.Guid
id
Asset unique ID. |
System.Double
timeoutInMilliseconds
Custom timeout value in milliseconds. |
Returns
Asset
Asset instance if loaded, null otherwise |
Load(String, Double)
Loads asset to the Content Pool and holds it until it won't be referenced by any object. Returns null if asset is missing. Actual asset data loading is performed on a other thread in async. The current thread execution is blocked until asset is loaded. Waits until asset will be loaded. It's equivalent to LoadAsync + WaitForLoaded.
Declaration
public static Asset Load(string path, double timeoutInMilliseconds = 30000)
Parameters
System.String
path
Path to the asset. |
System.Double
timeoutInMilliseconds
Custom timeout value in milliseconds. |
Returns
Asset
Asset instance if loaded, null otherwise |
Load<T>(Guid, Double)
Loads asset to the Content Pool and holds it until it won't be referenced by any object. Returns null if asset is missing. Actual asset data loading is performed on a other thread in async. Waits until asset will be loaded. It's equivalent to LoadAsync + WaitForLoaded.
Declaration
public static T Load<T>(Guid id, double timeoutInMilliseconds = 30000)
where T : Asset
Parameters
System.Guid
id
Asset unique ID. |
System.Double
timeoutInMilliseconds
Custom timeout value in milliseconds. |
Returns
T
Asset instance if loaded, null otherwise |
Type Parameters
T
Type of the asset to load. Includes any asset types derived from the type. |
Load<T>(String, Double)
Loads asset to the Content Pool and holds it until it won't be referenced by any object. Returns null if asset is missing. Actual asset data loading is performed on a other thread in async. Waits until asset will be loaded. It's equivalent to LoadAsync + WaitForLoaded.
Declaration
public static T Load<T>(string path, double timeoutInMilliseconds = 30000)
where T : Asset
Parameters
System.String
path
Path to the asset. |
System.Double
timeoutInMilliseconds
Custom timeout value in milliseconds. |
Returns
T
Asset instance if loaded, null otherwise |
Type Parameters
T
Type of the asset to load. Includes any asset types derived from the type. |
LoadAsync(Guid)
Loads asset to the Content Pool and holds it until it won't be referenced by any object. Returns null if asset is missing. Actual asset data loading is performed on a other thread in async.
Declaration
public static Asset LoadAsync(Guid id)
Parameters
System.Guid
id
Asset unique ID. |
Returns
Asset
Asset instance if loaded, null otherwise |
LoadAsync(Guid, Type)
Loads asset and holds it until it won't be referenced by any object. Returns null if asset is missing. Actual asset data loading is performed on a other thread in async.
Declaration
[Unmanaged]
public static Asset LoadAsync(Guid id, [TypeReference] Type type)
Parameters
System.Guid
id
Asset unique ID |
System.Type
type
The asset type. If loaded object has different type (excluding types derived from the given) the loading fails. |
Returns
Asset
Loaded asset or null if cannot |
LoadAsync(String)
Loads asset to the Content Pool and holds it until it won't be referenced by any object. Returns null if asset is missing. Actual asset data loading is performed on a other thread in async.
Declaration
public static Asset LoadAsync(string path)
Parameters
System.String
path
Path to the asset. |
Returns
Asset
Asset instance if loaded, null otherwise |
LoadAsync<T>(Guid)
Loads asset to the Content Pool and holds it until it won't be referenced by any object. Returns null if asset is missing. Actual asset data loading is performed on a other thread in async.
Declaration
public static T LoadAsync<T>(Guid id)
where T : Asset
Parameters
System.Guid
id
Asset unique ID. |
Returns
T
Asset instance if loaded, null otherwise. |
Type Parameters
T
Type of the asset to load. Includes any asset types derived from the type. |
LoadAsync<T>(String)
Loads asset to the Content Pool and holds it until it won't be referenced by any object. Returns null if asset is missing. Actual asset data loading is performed on a other thread in async.
Declaration
public static T LoadAsync<T>(string path)
where T : Asset
Parameters
System.String
path
Path to the asset. |
Returns
T
Asset instance if loaded, null otherwise. |
Type Parameters
T
Type of the asset to load. Includes any asset types derived from the type. |
RenameAsset(String, String)
Renames the asset.
Declaration
[Unmanaged]
public static bool RenameAsset(string oldPath, string newPath)
Parameters
System.String
oldPath
The old asset path. |
System.String
newPath
The new asset path. |
Returns
System.Boolean
True if failed, otherwise false. |
UnloadAsset(Asset)
Unloads the specified asset.
Declaration
[Unmanaged]
public static void UnloadAsset(Asset asset)
Parameters
Asset
asset
The asset. |
Events
AssetDisposing
Occurs when asset is being disposed and will be unloaded (by force). All references to it should be released.
Declaration
[Unmanaged]
public static event Action<Asset> AssetDisposing
Event Type
System.Action<Asset>
|
AssetReloading
Occurs when asset is being reloaded and will be unloaded (by force) to be loaded again (e.g. after reimport). Always called from the main thread.
Declaration
[Unmanaged]
public static event Action<Asset> AssetReloading
Event Type
System.Action<Asset>
|