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...
|
class | Entry |
| Internal representation of an asset in the DB. Serialized data remains immutable, while the runtime data is mutable. 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...
|
|
|
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...
|
|
|
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...
|
|
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).
◆ OnEnable()
void Quantum.QuantumUnityDB.OnEnable |
( |
| ) |
|
|
inlineprotected |
Initializes the DB with asset sources collected from the project.
◆ OnDisable()
override void Quantum.QuantumUnityDB.OnDisable |
( |
| ) |
|
|
inlineprotected |
Disposes all the assets that have been loaded by the DB.
◆ UpdateGlobal()
static void Quantum.QuantumUnityDB.UpdateGlobal |
( |
| ) |
|
|
inlinestatic |
Updates Global DB, if loaded. Must be called from the main thread. Call periodically, if assets are loaded/unloaded without the simulation running.
◆ UnloadGlobal()
static bool Quantum.QuantumUnityDB.UnloadGlobal |
( |
| ) |
|
|
inlinestatic |
Unloads Global, if already loaded and unloads any asset that has been loaded. Next call to Global will load the DB again.
◆ OnUnloadedAsGlobal()
override void Quantum.QuantumUnityDB.OnUnloadedAsGlobal |
( |
bool |
destroyed | ) |
|
|
inlineprotected |
Unloads all the assets that have been loaded by the Global DB.
- Parameters
-
◆ AddSource()
void Quantum.QuantumUnityDB.AddSource |
( |
IQuantumAssetObjectSource |
source, |
|
|
AssetGuid |
guid, |
|
|
string |
path = null |
|
) |
| |
|
inline |
Registers a source for the asset with the given guid and an optional path .
- Parameters
-
◆ AddAsset()
void Quantum.QuantumUnityDB.AddAsset |
( |
AssetObject |
asset | ) |
|
|
inline |
Registers a static asset. This is equivalent to calling AddSource with a QuantumAssetObjectSourceStatic.
- Parameters
-
◆ RemoveSource() [1/2]
bool Quantum.QuantumUnityDB.RemoveSource |
( |
AssetGuid |
guid, |
|
|
out(IQuantumAssetObjectSource source, bool isAcquired) |
result |
|
) |
| |
|
inline |
Removes the source for the asset with the given guid .
- Parameters
-
- Returns
true
if there was a matching source to remove
◆ RemoveSource() [2/2]
bool Quantum.QuantumUnityDB.RemoveSource |
( |
AssetGuid |
guid | ) |
|
|
inline |
Removes the source for the asset with the given guid .
- Parameters
-
- Returns
true
if there was a matching source to remove
◆ FindGlobalAssetGuid()
Finds the asset GUID based on the provided query.
- Parameters
-
query | The query to filter the assets. |
- Returns
- The asset GUID.
◆ FindGlobalAssetGuids() [1/2]
Finds the asset GUIDs based on the provided query.
- Parameters
-
query | The query to filter the assets. |
result | The list to store results. |
◆ FindGlobalAssetGuids() [2/2]
Finds the asset GUIDs based on the provided query.
- Parameters
-
query | The query to filter the assets. |
- Returns
- The list of asset GUIDs.
◆ GetGlobalAsset< T >()
- Returns
- The loaded asset object or
null
, if not found or its type does not match T .
◆ GetGlobalAsset()
static AssetObject Quantum.QuantumUnityDB.GetGlobalAsset |
( |
string |
assetPath | ) |
|
|
inlinestatic |
Gets an asset based on its path.
- Parameters
-
assetPath | The path of the asset. |
- Returns
- The asset object.
◆ TryGetGlobalAsset< T >() [1/2]
static bool Quantum.QuantumUnityDB.TryGetGlobalAsset< T > |
( |
AssetGuid |
assetGuid, |
|
|
out T |
result |
|
) |
| |
|
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.
- Parameters
-
assetGuid | The guid of the asset. |
result | The result asset object. |
- Returns
true
if the asset of type T exists.
◆ TryGetGlobalAsset< T >() [2/2]
static bool Quantum.QuantumUnityDB.TryGetGlobalAsset< T > |
( |
string |
assetPath, |
|
|
out T |
result |
|
) |
| |
|
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.
- Parameters
-
assetPath | The path of the asset. |
result | The result asset object. |
- Returns
true
if the asset of type T exists.
◆ GetAssetSource() [1/2]
IQuantumAssetObjectSource Quantum.QuantumUnityDB.GetAssetSource |
( |
AssetGuid |
assetGuid | ) |
|
|
inline |
Returns the asset source with the given assetGuid . Asset does not get loaded in the process.
- Parameters
-
- Returns
- Asset source or
null
if the asset is not found
◆ GetAssetSource() [2/2]
IQuantumAssetObjectSource Quantum.QuantumUnityDB.GetAssetSource |
( |
string |
assetPath | ) |
|
|
inline |
Returns the asset source with the given assetPath . Asset does not get loaded in the process.
- Parameters
-
- Returns
- Asset source or
null
if the asset is not found
◆ GetAssetGuid()
AssetGuid Quantum.QuantumUnityDB.GetAssetGuid |
( |
string |
path | ) |
|
|
inline |
◆ GetAssetPath()
string Quantum.QuantumUnityDB.GetAssetPath |
( |
AssetGuid |
assetGuid | ) |
|
|
inline |
Returns path for the asset with the given assetGuid . Asset does not get loaded in the process.
- Parameters
-
- Returns
- Asset path or an empty string, if not found
◆ DisposeAsset()
bool Quantum.QuantumUnityDB.DisposeAsset |
( |
AssetGuid |
guid, |
|
|
bool |
immediate = false |
|
) |
| |
|
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.
- Parameters
-
- Returns
false
if the asset is not found
- Exceptions
-
InvalidOperationException | If called from non-main thread |
◆ DisposeAllAssetsImmediate()
void Quantum.QuantumUnityDB.DisposeAllAssetsImmediate |
( |
| ) |
|
|
inline |
Disposes all the assets that have been loaded by the DB.
- Exceptions
-
InvalidOperationException | If called from non-main thread |
◆ GetAsset()
Loads the asset with the given guid synchronously.
- Parameters
-
guid | Guid of the asset to load |
- Returns
- Asset reference or
null
if the asset is not found
Implements Quantum.IResourceManager.
◆ LoadAssetAsync()
bool Quantum.QuantumUnityDB.LoadAssetAsync |
( |
AssetGuid |
guid | ) |
|
|
inline |
Loads the asset with the given guid asynchronously.
- Parameters
-
guid | Guid of the asset to load |
- Returns
false
if the asset is not found, true
otherwise
Implements Quantum.IResourceManager.
◆ GetAssetType()
Type Quantum.QuantumUnityDB.GetAssetType |
( |
AssetGuid |
guid | ) |
|
|
inline |
Returns the type of the asset with the given guid .
- Parameters
-
guid | Guid of the asset to find |
- Returns
null
if the asset is not found or its source does not have type info, type instance otherwise.
Implements Quantum.IResourceManager.
◆ DefaultPath
const string Quantum.QuantumUnityDB.DefaultPath = "Assets/QuantumUser/Resources/QuantumUnityDB.qunitydb" |
|
static |
The default location of the DB asset.
◆ NestedPathSeparator
const char Quantum.QuantumUnityDB.NestedPathSeparator = '|' |
|
static |
Character used to separate nested assets names from their parents path.
◆ Entries
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.
◆ Version
uint Quantum.QuantumUnityDB.Version => _version |
A version number that is increased every time an asset is added or removed.
◆ Global
Returns the global DB. If the DB is not loaded, it will be loaded.
◆ AssetObjectDisposing
Raised when an asset is unloaded.