A DynamicAssetDB is a database of assets that can be added and removed at runtime. For late joiners, contents are serialized and deserialized using an IAssetSerializer.
More...
A DynamicAssetDB is a database of assets that can be added and removed at runtime. For late joiners, contents are serialized and deserialized using an IAssetSerializer.
All the DynamicAssetDB instances share ownership over assets due to DynamicAssetDB.CopyFrom sharing reference counts. AssetObject.Loaded is called when an asset is added or replaced, AssetObject.Disposed is called when assets' reference count reaches zero due to DynamicAssetDB.DisposeAsset, DynamicAssetDB.CopyFrom, DynamicAssetDB.ReplaceAsset or DynamicAssetDB.Dispose.
- See also
- IsLegacyModeEnabled
◆ DynamicAssetDB() [1/2]
Quantum.DynamicAssetDB.DynamicAssetDB |
( |
Native.Allocator |
allocator, |
|
|
bool |
isLegacyMode = false , |
|
|
AssetGuid? |
lastGuid = default |
|
) |
| |
|
inline |
Initializes a new instance of the DynamicAssetDB class.
- Parameters
-
allocator | |
lastGuid | The lastGuid value to set. |
isLegacyMode | |
◆ DynamicAssetDB() [2/2]
Initializes a new instance of the DynamicAssetDB class with the same state as another DynamicAssetDB instance.
- Parameters
-
other | The DynamicAssetDB instance to copy from. |
◆ AddAsset()
Adds an asset to the DynamicAssetDB and assigns it a new AssetGuid.
- Parameters
-
- Returns
- The AssetGuid assigned to the added asset.
◆ AddAssetWithValidDynamicGuid()
void Quantum.DynamicAssetDB.AddAssetWithValidDynamicGuid |
( |
AssetObject |
asset | ) |
|
|
inline |
Adds an asset to the DynamicAssetDB with a valid dynamic AssetGuid. Does not call AssetObject.Loaded
- Parameters
-
◆ ReplaceAsset()
Replaces an asset with the specified AssetGuid with a new asset.
- Parameters
-
guid | The AssetGuid of the asset to replace. |
asset | The new asset to replace with. |
- Returns
- Replaced asset or
null
, if there was no asset with guid
◆ DisposeAsset()
bool Quantum.DynamicAssetDB.DisposeAsset |
( |
AssetGuid |
guid | ) |
|
|
inline |
Disposes the asset with the specified AssetGuid from the DynamicAssetDB.
- Parameters
-
guid | The AssetGuid of the asset to dispose. |
- Returns
true
if the asset was successfully disposed, false
otherwise.
◆ CopyFrom()
Copies the state of another DynamicAssetDB instance to this instance.
- Parameters
-
other | The DynamicAssetDB instance to copy from. |
◆ Deserialize()
void Quantum.DynamicAssetDB.Deserialize |
( |
byte[] |
bytes, |
|
|
IAssetSerializer |
assetSerializer |
|
) |
| |
|
inline |
Deserializes the DynamicAssetDB from a byte array using the specified assetSerializer and allocator.
- Parameters
-
bytes | The byte array containing the serialized DynamicAssetDB. |
assetSerializer | The asset serializer to use for deserialization. |
◆ Serialize() [1/2]
Serializes the DynamicAssetDB using the specified serializer and returns the serialized byte array.
- Parameters
-
serializer | The serializer to use for serialization. |
- Returns
- The serialized byte array.
◆ Serialize() [2/2]
void Quantum.DynamicAssetDB.Serialize |
( |
IAssetSerializer |
serializer, |
|
|
out byte[] |
header, |
|
|
out byte[] |
assets |
|
) |
| |
|
inline |
Serializes the DynamicAssetDB using the specified serializer and assigns the serialized header and assets byte arrays.
- Parameters
-
serializer | The serializer to use for serialization. |
header | The serialized header byte array. |
assets | The serialized assets byte array. |
◆ FindAsset< T >() [1/2]
Finds an asset of type T with the specified AssetGuid.
- Template Parameters
-
T | The type of asset to find. |
- Parameters
-
guid | The AssetGuid of the asset to find. |
- Returns
- The asset of type T with the specified AssetGuid, or
null
if not found.
◆ FindAsset() [1/2]
Finds an asset of type AssetObject with the specified AssetGuid.
- Parameters
-
guid | The AssetGuid of the asset to find. |
- Returns
- The asset of type AssetObject with the specified AssetGuid, or
null
if not found.
◆ FindAsset< T >() [2/2]
Finds an asset of type T with the specified path.
- Template Parameters
-
T | The type of asset to find. |
- Parameters
-
path | The path of the asset to find. |
- Returns
- The asset of type T with the specified path, or
null
if not found.
◆ FindAsset() [2/2]
AssetObject Quantum.DynamicAssetDB.FindAsset |
( |
string |
path | ) |
|
Finds an asset of type AssetObject with the specified path.
- Parameters
-
path | The path of the asset to find. |
- Returns
- The asset of type AssetObject with the specified path, or
null
if not found.
◆ GetAssetState()
AssetObjectState Quantum.DynamicAssetDB.GetAssetState |
( |
AssetGuid |
guid | ) |
|
|
inline |
Gets the state of the asset with the specified AssetGuid.
- Parameters
-
guid | The AssetGuid of the asset to get the state of. |
- Returns
- The state of the asset with the specified AssetGuid.
◆ Dispose()
void Quantum.DynamicAssetDB.Dispose |
( |
| ) |
|
|
inline |
◆ Allocator
◆ IsLegacyModeEnabled
readonly bool Quantum.DynamicAssetDB.IsLegacyModeEnabled |
If true
, the legacy dynamic DB behaviour will be used:
◆ IsEmpty
bool Quantum.DynamicAssetDB.IsEmpty => _head.ByGuid.Count == 0 |
Gets a value indicating whether the DynamicAssetDB is empty.
◆ NextGuid
Gets the next available AssetGuid.
◆ Assets
AssetEnumerable Quantum.DynamicAssetDB.Assets => new AssetEnumerable(this) |
Gets all the assets in the DynamicAssetDB.