Photon Quantum 3.0.0

Public Member Functions | Properties | List of all members
Quantum.ResourceManagerStatic Class Reference

A static resource manager that can be used to manage assets in a deterministic context. All the assets are known and instantiated ahead of time. More...

Inheritance diagram for Quantum.ResourceManagerStatic:
Quantum.IResourceManager

Public Member Functions

 ResourceManagerStatic (AssetObject[] assets, Native.Allocator allocator, bool allowDisposals=true)
 Initializes a new instance of the ResourceManagerStatic class with assets. More...
 
 ResourceManagerStatic (Native.Allocator allocator, bool allowDisposals=true)
 Initializes a new instance of the ResourceManagerStatic class. More...
 
void AddAsset (AssetObject asset, bool isLoaded)
 Adds an asset to the resource manager. More...
 
void AddAssets (IEnumerable< AssetObject > assets, bool areLoaded)
 Adds a collection of assets to the resource manager. More...
 
void Dispose ()
 Disposes the resource manager and all its assets. More...
 
bool DisposeAsset (AssetGuid guid)
 Enqueues the asset with the specified GUID for disposal. The actual disposal will happen in the next call to Update from the main thread. More...
 
bool FindNextAssetGuid (ref AssetObjectQuery query, out AssetGuid guid)
 Finds the next asset GUID that matches the specified query. More...
 
AssetObject GetAsset (AssetGuid guid)
 Gets the asset with the specified GUID. More...
 
AssetGuid GetAssetGuid (string path)
 Gets the GUID of the asset with the specified path. More...
 
AssetObjectState GetAssetState (AssetGuid guid)
 Gets the state of the asset with the specified GUID. More...
 
Type GetAssetType (AssetGuid guid)
 Gets the type of the asset with the specified GUID. More...
 
bool LoadAssetAsync (AssetGuid guid)
 Loads the asset with the specified GUID asynchronously. More...
 
void ProcessDisposals ()
 Processes asset disposals. More...
 
void Update (bool inSimulation=false, in Profiler profiler=default)
 Updates the resource manager. More...
 

Properties

ResourceManagerStatic FallbackResourceManager [get, set]
 Gets or sets the fallback resource manager. More...
 

Additional Inherited Members

- Events inherited from Quantum.IResourceManager
AssetObjectDisposingDelegate AssetObjectDisposing
 Invoked before AssetObject.Disposed. Exposed as an event, because assets may be disposed externally. Any code using any form of asset caching needs to be aware of that happening. More...
 

Detailed Description

A static resource manager that can be used to manage assets in a deterministic context. All the assets are known and instantiated ahead of time.

Constructor & Destructor Documentation

◆ ResourceManagerStatic() [1/2]

Quantum.ResourceManagerStatic.ResourceManagerStatic ( Native.Allocator  allocator,
bool  allowDisposals = true 
)
inline

Initializes a new instance of the ResourceManagerStatic class.

Parameters
allocatorThe allocator to use for managing memory.
allowDisposalsWhether asset disposals are allowed.

◆ ResourceManagerStatic() [2/2]

Quantum.ResourceManagerStatic.ResourceManagerStatic ( AssetObject[]  assets,
Native.Allocator  allocator,
bool  allowDisposals = true 
)
inline

Initializes a new instance of the ResourceManagerStatic class with assets.

Parameters
assetsThe array of assets. Each asset is not considered loaded yet, so accessing them for the first time will result with AssetObject.Loaded(IResourceManager, Native.Allocator) being called
allocatorThe allocator to use for managing memory.
allowDisposalsWhether asset disposals are allowed.

Member Function Documentation

◆ AddAssets()

void Quantum.ResourceManagerStatic.AddAssets ( IEnumerable< AssetObject assets,
bool  areLoaded 
)
inline

Adds a collection of assets to the resource manager.

Parameters
assetsThe collection of assets to add.
areLoadedWhether the assets are already loaded. If false, accessing them for the first time will result with AssetObject.Loaded(IResourceManager, Native.Allocator) being called

◆ AddAsset()

void Quantum.ResourceManagerStatic.AddAsset ( AssetObject  asset,
bool  isLoaded 
)
inline

Adds an asset to the resource manager.

Parameters
assetThe asset to add.
isLoadedWhether the asset is already loaded. If false, accessing it for the first time will result with AssetObject.Loaded(IResourceManager, Native.Allocator) being called

◆ Dispose()

void Quantum.ResourceManagerStatic.Dispose ( )
inline

Disposes the resource manager and all its assets.

◆ DisposeAsset()

bool Quantum.ResourceManagerStatic.DisposeAsset ( AssetGuid  guid)
inline

Enqueues the asset with the specified GUID for disposal. The actual disposal will happen in the next call to Update from the main thread.

Parameters
guidThe GUID of the asset to dispose.
Returns
true if the asset was enqueued for disposal.

Implements Quantum.IResourceManager.

◆ GetAsset()

AssetObject Quantum.ResourceManagerStatic.GetAsset ( AssetGuid  guid)
inline

Gets the asset with the specified GUID.

Parameters
guidThe GUID of the asset to get.
Returns
The asset with the specified GUID, or null if the asset does not exist.

Implements Quantum.IResourceManager.

◆ LoadAssetAsync()

bool Quantum.ResourceManagerStatic.LoadAssetAsync ( AssetGuid  guid)
inline

Loads the asset with the specified GUID asynchronously.

Parameters
guidThe GUID of the asset to load.
Returns
true if the asset exists; otherwise, false.

Implements Quantum.IResourceManager.

◆ GetAssetGuid()

AssetGuid Quantum.ResourceManagerStatic.GetAssetGuid ( string  path)
inline

Gets the GUID of the asset with the specified path.

Parameters
pathThe path of the asset.
Returns
The GUID of the asset with the specified path, or AssetGuid.Invalid if the asset does not exist.

Implements Quantum.IResourceManager.

◆ GetAssetType()

Type Quantum.ResourceManagerStatic.GetAssetType ( AssetGuid  guid)
inline

Gets the type of the asset with the specified GUID.

Parameters
guidThe GUID of the asset.
Returns
The type of the asset with the specified GUID, or null if the asset does not exist.

Implements Quantum.IResourceManager.

◆ FindNextAssetGuid()

bool Quantum.ResourceManagerStatic.FindNextAssetGuid ( ref AssetObjectQuery  query,
out AssetGuid  guid 
)
inline

Finds the next asset GUID that matches the specified query.

Parameters
queryThe query to match.
guidThe GUID of the next matching asset.
Returns
true if a matching asset was found; otherwise, false.

Implements Quantum.IResourceManager.

◆ Update()

void Quantum.ResourceManagerStatic.Update ( bool  inSimulation = false,
in Profiler  profiler = default 
)
inline

Updates the resource manager.

Parameters
inSimulationWhether the update is happening in a simulation context.
profilerThe profiler to use for profiling.

Implements Quantum.IResourceManager.

◆ GetAssetState()

AssetObjectState Quantum.ResourceManagerStatic.GetAssetState ( AssetGuid  guid)
inline

Gets the state of the asset with the specified GUID.

Parameters
guidThe GUID of the asset.
Returns
The state of the asset with the specified GUID, or AssetObjectState.NotFound if the asset does not exist.

Implements Quantum.IResourceManager.

◆ ProcessDisposals()

void Quantum.ResourceManagerStatic.ProcessDisposals ( )
inline

Processes asset disposals.

Property Documentation

◆ FallbackResourceManager

ResourceManagerStatic Quantum.ResourceManagerStatic.FallbackResourceManager
getset

Gets or sets the fallback resource manager.