Class VisAssetManager
The VisAssetManager is where all VisAssets are stored within the
ABREngine. VisAssets can be loaded and fetched from various sources
defined in VisAssetFetchers. Currently, VisAssets may be loaded from any of the following:
- The state itself (`localVisAssets`)
- The media directory on the machine ABR is running on
- Any Resources folder (in Assets or in any Package)
- A VisAsset server
Namespace: IVLab.ABREngine
Assembly: IVLab.ABREngine.Runtime.dll
Syntax
public class VisAssetManager
Examples
VisAssets can be loaded manually from your media folder, resources
folder, or a network resource. This example loads a colormap
66b3cde4-034d-11eb-a7e6-005056bae6d8 from Resources (it's included in
the ABREngine/Resources/media folder).
public class VisAssetManagerExample : MonoBehaviour
{
void Start()
{
// Note, we could've used `LoadVisAsset` explicitly here, but
// GetVisAsset will automatically try to load the VisAsset if it
// doesn't already exist.
ColormapVisAsset cmap = ABREngine.Instance.VisAssets.GetVisAsset<ColormapVisAsset>(new System.Guid("66b3cde4-034d-11eb-a7e6-005056bae6d8"));
}
void Update()
{
// If you want to access the colormap later, you can use `GetVisAsset`.
ColormapVisAsset cmapInUpdate = ABREngine.Instance.VisAssets.GetVisAsset<ColormapVisAsset>(new System.Guid("66b3cde4-034d-11eb-a7e6-005056bae6d8");
}
}
You can also get the "default" visasset for a few VisAsset types. Keep in mind that the GetDefault<T>() method may not be defined for the VisAsset type that you want to get!
public class VisAssetManagerExample : MonoBehaviour
{
void Start()
{
ColormapVisAsset cmap = ABREngine.Instance.VisAssets.GetDefault<ColormapVisAsset>() as ColormapVisAsset;
}
}
Constructors
| Improve this Doc View SourceVisAssetManager(string)
Initialize a new VisAssetManager and define all of the places VisAssets may be loaded from.
Declaration
public VisAssetManager(string visassetPath)
Parameters
| Type | Name | Description |
|---|---|---|
| string | visassetPath | Path to the VisAssets folder within ABR's media folder. |
Fields
| Improve this Doc View SourceVISASSET_JSON
Name of the artifact.json files that each VisAsset has
Declaration
public const string VISASSET_JSON = "artifact.json"
Field Value
| Type | Description |
|---|---|
| string |
appDataPath
Application data path for internal access
Declaration
public string appDataPath
Field Value
| Type | Description |
|---|---|
| string |
Properties
| Improve this Doc View SourceLocalVisAssets
Any (custom) visassets that are solely described inside the state and do not exist on disk or on a server somewhere.
Declaration
public JObject LocalVisAssets { get; set; }
Property Value
| Type | Description |
|---|---|
| JObject |
VisAssetGradients
Any VisAsset gradients that are contained within the state (updated directly from state)
Declaration
public Dictionary<string, RawVisAssetGradient> VisAssetGradients { get; set; }
Property Value
| Type | Description |
|---|---|
| Dictionary<string, RawVisAssetGradient> |
Methods
| Improve this Doc View SourceGetDefault<T>()
Obtain the default visasset for a particular type, if there is one.
Declaration
public IVisAsset GetDefault<T>() where T : IVisAsset
Returns
| Type | Description |
|---|---|
| IVisAsset |
Type Parameters
| Name | Description |
|---|---|
| T |
Remarks
If using the VisAsset immediately as the type T, you will likely need to do a cast (e.g. ColormapVisAsset c = ....GetDefault<ColormapVisAsset>() as ColormapVisAsset).
GetVisAsset<T>(Guid)
Get a visasset by its unique identifier.
Declaration
public T GetVisAsset<T>(Guid uuid) where T : IVisAsset
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | uuid | UUID of the VisAsset to get from the engine. |
Returns
| Type | Description |
|---|---|
| T | Returns the VisAsset, if found. If not found, tries to load the VisAsset then return it. |
Type Parameters
| Name | Description |
|---|---|
| T | Any VisAsset type. |
GetVisAssets()
Get the UUIDs of every VisAsset that's been imported into ABR
Declaration
public List<Guid> GetVisAssets()
Returns
| Type | Description |
|---|---|
| List<Guid> | Returns a list containing UUIDs of each VisAsset in ABR. |
LoadVisAsset(Guid, bool)
Load a particular VisAsset described by its UUID.
Declaration
public IVisAsset LoadVisAsset(Guid visAssetUUID, bool replaceExisting = false)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | visAssetUUID | |
| bool | replaceExisting |
Returns
| Type | Description |
|---|---|
| IVisAsset | Returns the IVisAsset that was loaded, or |
LoadVisAssetPalette()
Load all VisAssets located in the Media directory into memory.
Declaration
[Obsolete("LoadVisAssetPalette is obsolete because it only takes into consideration VisAssets in the media directory")]
public void LoadVisAssetPalette()
LoadVisAsset<T>(Guid, bool)
Load a VisAsset of a specific type.
Declaration
public T LoadVisAsset<T>(Guid visAssetUUID, bool replaceExisting = false) where T : IVisAsset
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | visAssetUUID | UUID of the VisAsset to load from any VisAsset loader. |
| bool | replaceExisting |
Returns
| Type | Description |
|---|---|
| T | Returns the VisAsset of type |
Type Parameters
| Name | Description |
|---|---|
| T | Any VisAsset type. |
TryGetVisAsset(Guid, out IVisAsset)
Attempt to retrieve a VisAsset.
Declaration
public bool TryGetVisAsset(Guid guid, out IVisAsset visAsset)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | guid | |
| IVisAsset | visAsset |
Returns
| Type | Description |
|---|---|
| bool | Returns true if the VisAsset is currently loaded into the memory. |
UnloadVisAsset(Guid)
Unload a particular VisAsset described by its UUID.
Declaration
public void UnloadVisAsset(Guid visAssetUUID)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | visAssetUUID |
Remarks
Note that this method does not check if the VisAsset is in use, so be careful when calling it!