Class BlobAssetStore
Purpose of this class is to provide a consistent cache of BlobAsset object in order to avoid rebuilding them when it is not necessary
Namespace: Unity.Entities
Syntax
public class BlobAssetStore : IDisposable
Remarks
Right now the lifetime scope of this cache is bound to the LiveLinkDiffGenerator's one and it is scoped by SubScene. In other words the cache is created when we enter edit mode for a given SubScene and it is released when we close edit mode. And instance of this cache is exposed in GameObjectConversionSettings to allow users to query and avoid rebuilding assets. During conversion process the user must rely on the BlobAssetComputationContext<TS, TB> to associate the BlobAsset with their corresponding Authoring UnityObject and to determine which ones are to compute. Thread-safety: nothing is thread-safe, we assume this class is consumed through the main-thread only. Calling Dispose on an instance will reset the content and dispose all BlobAssetReference object stored.
Constructors
BlobAssetStore()
Declaration
public BlobAssetStore()
Methods
Contains<T>(Hash128)
Check if the Store contains a BlobAsset of a given type and hash
Declaration
public bool Contains<T>(Hash128 key)
Parameters
Type | Name | Description |
---|---|---|
Hash128 | key | The hash associated with the BlobAsset |
Returns
Type | Description |
---|---|
Boolean | true if the Store contains the BlobAsset or false if it doesn't |
Type Parameters
Name | Description |
---|---|
T | The type of the BlobAsset |
Dispose()
Calling dispose will reset the cache content and release all the BlobAssetReference that were stored
Declaration
public void Dispose()
Remove<T>(Hash128, Boolean)
Remove a BlobAssetReference from the store
Declaration
public bool Remove<T>(Hash128 key, bool releaseBlobAsset)
Parameters
Type | Name | Description |
---|---|---|
Hash128 | key | The key associated with the BlobAssetReference |
Boolean | releaseBlobAsset | If true the BlobAsset data will be released |
Returns
Type | Description |
---|---|
Boolean | True if the BLobAsset was removed from the store, false if it wasn't found |
Type Parameters
Name | Description |
---|---|
T | The type of the BlobAsset |
ResetCache(Boolean)
Call this method to clear the whole content of the Cache
Declaration
public void ResetCache(bool disposeAllBlobAssetReference)
Parameters
Type | Name | Description |
---|---|---|
Boolean | disposeAllBlobAssetReference | If true all BlobAssetReference present in the cache will be dispose. If false they will remain present in memory |
TryAdd<T>(Hash128, BlobAssetReference<T>)
Get a BlobAssetReference from its key
Declaration
public bool TryAdd<T>(Hash128 key, BlobAssetReference<T> result)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
Hash128 | key | The key associated with the BlobAssetReference |
BlobAssetReference<T> | result | The BlobAssetReference if found or default |
Returns
Type | Description |
---|---|
Boolean | true if the BlobAssetReference was found, false if not found |
Type Parameters
Name | Description |
---|---|
T | The type of BlobAsset |
TryGet<T>(Hash128, out BlobAssetReference<T>)
Try to access to a BlobAssetReference from its key
Declaration
public bool TryGet<T>(Hash128 key, out BlobAssetReference<T> blobAssetReference)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
Hash128 | key | The key associated with the BlobAssetReference when it was added to the cache |
BlobAssetReference<T> | blobAssetReference | The corresponding BlobAssetReference or default if none was found |
Returns
Type | Description |
---|---|
Boolean |
Type Parameters
Name | Description |
---|---|
T | The type of BlobAsset |