At runtime, servers as the default implementation of IResourceManager for Unity. During edit time, it collects and keeps track of all the AssetObject assets in the project. Collected assets are stored as IQuantumAssetObjectSource references, avoiding forming hard-references to the actual assets (if possible). More...
Classes | |
class | Entry |
Internal representation of an asset in the DB. Serialized data remains immutable, while the runtime data is mutable. More... | |
Public Member Functions | |
void | AddAsset (AssetObject asset) |
Registers a static asset. This is equivalent to calling AddSource with a QuantumAssetObjectSourceStatic. More... | |
void | AddSource (IQuantumAssetObjectSource source, AssetGuid guid, string path=null) |
Registers a source for the asset with the given guid and an optional path . More... | |
void | DisposeAllAssetsImmediate () |
Disposes all the assets that have been loaded by the DB. More... | |
bool | DisposeAsset (AssetGuid guid, bool immediate=false) |
Disposes the asset with the given guid . If immediate is true , the asset is disposed immediately, otherwise it's scheduled for disposal during the next update. More... | |
bool | FindNextAssetGuid (ref AssetObjectQuery query, out AssetGuid guid) |
Finds the next asset GUID based on the provided query. | |
AssetObject | GetAsset (AssetGuid guid) |
Loads the asset with the given guid synchronously. More... | |
AssetGuid | GetAssetGuid (string path) |
Converts a Quantum asset path to a Quantum asset guid. More... | |
string | GetAssetPath (AssetGuid assetGuid) |
Returns path for the asset with the given assetGuid . Asset does not get loaded in the process. More... | |
IQuantumAssetObjectSource | GetAssetSource (AssetGuid assetGuid) |
Returns the asset source with the given assetGuid . Asset does not get loaded in the process. More... | |
IQuantumAssetObjectSource | GetAssetSource (string assetPath) |
Returns the asset source with the given assetPath . Asset does not get loaded in the process. More... | |
AssetObjectState | GetAssetState (AssetGuid guid) |
Gets the state of an asset. | |
Type | GetAssetType (AssetGuid guid) |
Returns the type of the asset with the given guid . More... | |
bool | LoadAssetAsync (AssetGuid guid) |
Loads the asset with the given guid asynchronously. More... | |
bool | RemoveSource (AssetGuid guid) |
Removes the source for the asset with the given guid . More... | |
bool | RemoveSource (AssetGuid guid, out(IQuantumAssetObjectSource source, bool isAcquired) result) |
Removes the source for the asset with the given guid . More... | |
Static Public Member Functions | |
static AssetGuid | CreateRuntimeDeterministicGuid (AssetObject assetObject) |
Returns a deterministic AssetGuid for the given assetObject . Used for adding static assets at runtime to the DB. More... | |
static AssetGuid | CreateRuntimeDeterministicGuid (string assetName, Type assetType) |
Creates a deterministic guid based on the asset name and type. More... | |
static AssetGuid | CreateRuntimeDeterministicGuid (string path) |
Creates a deterministic GUID based and the provided path. More... | |
static AssetGuid | CreateRuntimeDeterministicGuid< T > (ReadOnlySpan< T > data, long initialHash=0) |
Creates a deterministic GUID based and the provided data. More... | |
static bool | DisposeGlobalAsset (AssetGuid assetGuid, bool immediate=false) |
static AssetGuid | FindGlobalAssetGuid (AssetObjectQuery query) |
Finds the asset GUID based on the provided query. More... | |
static List< AssetGuid > | FindGlobalAssetGuids (AssetObjectQuery query) |
Finds the asset GUIDs based on the provided query. More... | |
static void | FindGlobalAssetGuids (AssetObjectQuery query, List< AssetGuid > result) |
Finds the asset GUIDs based on the provided query. More... | |
static AssetObject | GetGlobalAsset (AssetRef assetRef) |
static AssetObject | GetGlobalAsset (string assetPath) |
Gets an asset based on its path. More... | |
static T | GetGlobalAsset< T > (AssetRef< T > assetRef) |
static AssetGuid | GetGlobalAssetGuid (string path) |
static string | GetGlobalAssetPath (AssetGuid assetGuid) |
static IQuantumAssetObjectSource | GetGlobalAssetSource (AssetGuid assetGuid) |
static IQuantumAssetObjectSource | GetGlobalAssetSource (string assetPath) |
static AssetObjectState | GetGlobalAssetState (AssetGuid guid) |
static Type | GetGlobalAssetType (AssetGuid guid) |
static bool | TryGetGlobalAsset< T > (AssetGuid assetGuid, out T result) |
Tries to get an asset of type T from the global DB. Note that if type T is not the same as the asset type, the asset will remain loaded in the memory until it is disposed. More... | |
static bool | TryGetGlobalAsset< T > (AssetRef assetRef, out T result) |
static bool | TryGetGlobalAsset< T > (AssetRef< T > assetRef, out T result) |
static bool | TryGetGlobalAsset< T > (string assetPath, out T result) |
Tries to get an asset of type T from the global DB. Note that if type T is not the same as the asset type, the asset will remain loaded in the memory until it is disposed. More... | |
static bool | UnloadGlobal () |
Unloads Global, if already loaded and unloads any asset that has been loaded. Next call to Global will load the DB again. More... | |
static void | UpdateGlobal () |
Updates Global DB, if loaded. Must be called from the main thread. Call periodically, if assets are loaded/unloaded without the simulation running. More... | |
Public Attributes | |
IReadOnlyList< Entry > | Entries => _entries |
Exposes the list of entries in the DB. Can be used to iterate asset sources at both runtime and edit time. More... | |
uint | Version => _version |
A version number that is increased every time an asset is added or removed. More... | |
Static Public Attributes | |
const string | DefaultPath = "Assets/QuantumUser/Resources/QuantumUnityDB.qunitydb" |
The default location of the DB asset. More... | |
const char | NestedPathSeparator = '|' |
Character used to separate nested assets names from their parents path. More... | |
Protected Member Functions | |
override void | OnDisable () |
Disposes all the assets that have been loaded by the DB. More... | |
void | OnEnable () |
Initializes the DB with asset sources collected from the project. More... | |
override void | OnUnloadedAsGlobal (bool destroyed) |
Unloads all the assets that have been loaded by the Global DB. More... | |
Properties | |
static new QuantumUnityDB | Global [get, set] |
Returns the global DB. If the DB is not loaded, it will be loaded. More... | |
Events | |
AssetObjectDisposingDelegate | AssetObjectDisposing |
Raised when an asset is unloaded. More... | |
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... | |
At runtime, servers as the default implementation of IResourceManager for Unity. During edit time, it collects and keeps track of all the AssetObject assets in the project. Collected assets are stored as IQuantumAssetObjectSource references, avoiding forming hard-references to the actual assets (if possible).
|
inlineprotected |
Initializes the DB with asset sources collected from the project.
|
inlineprotected |
Disposes all the assets that have been loaded by the DB.
|
inlinestatic |
Updates Global DB, if loaded. Must be called from the main thread. Call periodically, if assets are loaded/unloaded without the simulation running.
|
inlinestatic |
|
inlineprotected |
Unloads all the assets that have been loaded by the Global DB.
destroyed |
|
inlinestatic |
Returns a deterministic AssetGuid for the given assetObject . Used for adding static assets at runtime to the DB.
assetObject | The AssetObject generate the AssetGuid for. |
|
inlinestatic |
Creates a deterministic guid based on the asset name and type.
assetName | |
assetType |
|
inline |
Registers a source for the asset with the given guid and an optional path .
source | |
guid | |
path |
|
inline |
Registers a static asset. This is equivalent to calling AddSource with a QuantumAssetObjectSourceStatic.
asset |
|
inline |
Removes the source for the asset with the given guid .
guid | |
result |
true
if there was a matching source to remove
|
inline |
Removes the source for the asset with the given guid .
guid |
true
if there was a matching source to remove
|
inlinestatic |
Creates a deterministic GUID based and the provided path.
|
inlinestatic |
Creates a deterministic GUID based and the provided data.
T.GetHashCode() must be deterministic.
T | : | unmanaged |
|
inlinestatic |
Finds the asset GUID based on the provided query.
query | The query to filter the assets. |
|
inlinestatic |
Finds the asset GUIDs based on the provided query.
query | The query to filter the assets. |
result | The list to store results. |
|
inlinestatic |
Finds the asset GUIDs based on the provided query.
query | The query to filter the assets. |
|
inlinestatic |
null
, if not found or its type does not match T .T | : | AssetObject |
|
inlinestatic |
Gets an asset based on its path.
assetPath | The path of the asset. |
|
inlinestatic |
Tries to get an asset of type T from the global DB. Note that if type T is not the same as the asset type, the asset will remain loaded in the memory until it is disposed.
assetGuid | The guid of the asset. |
result | The result asset object. |
true
if the asset of type T exists.T | : | AssetObject |
|
inlinestatic |
Tries to get an asset of type T from the global DB. Note that if type T is not the same as the asset type, the asset will remain loaded in the memory until it is disposed.
assetPath | The path of the asset. |
result | The result asset object. |
true
if the asset of type T exists.T | : | AssetObject |
|
inline |
Returns the asset source with the given assetGuid . Asset does not get loaded in the process.
assetGuid |
null
if the asset is not found
|
inline |
Returns the asset source with the given assetPath . Asset does not get loaded in the process.
assetPath |
null
if the asset is not found
|
inline |
Converts a Quantum asset path to a Quantum asset guid.
path |
Implements Quantum.IResourceManager.
|
inline |
Returns path for the asset with the given assetGuid . Asset does not get loaded in the process.
assetGuid |
|
inline |
Disposes the asset with the given guid . If immediate is true
, the asset is disposed immediately, otherwise it's scheduled for disposal during the next update.
guid | |
immediate |
false
if the asset is not foundInvalidOperationException | If called from non-main thread |
|
inline |
Disposes all the assets that have been loaded by the DB.
InvalidOperationException | If called from non-main thread |
|
inline |
Loads the asset with the given guid synchronously.
guid | Guid of the asset to load |
null
if the asset is not foundImplements Quantum.IResourceManager.
|
inline |
Loads the asset with the given guid asynchronously.
guid | Guid of the asset to load |
false
if the asset is not found, true
otherwiseImplements Quantum.IResourceManager.
|
inline |
Returns the type of the asset with the given guid .
guid | Guid of the asset to find |
null
if the asset is not found or its source does not have type info, type instance otherwise.Implements Quantum.IResourceManager.
|
static |
The default location of the DB asset.
|
static |
Character used to separate nested assets names from their parents path.
IReadOnlyList<Entry> Quantum.QuantumUnityDB.Entries => _entries |
Exposes the list of entries in the DB. Can be used to iterate asset sources at both runtime and edit time.
uint Quantum.QuantumUnityDB.Version => _version |
A version number that is increased every time an asset is added or removed.
|
staticgetset |
Returns the global DB. If the DB is not loaded, it will be loaded.
AssetObjectDisposingDelegate Quantum.QuantumUnityDB.AssetObjectDisposing |
Raised when an asset is unloaded.