Sample description
Overview
-
This sample uses Addressables to reference resources containing ACB/AWB Assets to play Cues.
Get the prefab from the server and instantiate it by pressing the button in the window.
- Attention
- For this sample to work properly, the contents of the Addressables must first be built.
Scene information
Middleware | CRI ADX (CRI Atom) |
Sample | Asset Support Sample |
Location | /cri/unity/samples/UnityProject/Assets/CriAssetSamples/Scenes/ |
Scene file | Scene_02_Addressables.unity |
ACF Asset | /cri/unity/samples/UnityProject/Assets/CriAssetSamples/Data/DemoProj.acf |
ACB Asset | /cri/unity/samples/UnityProject/Assets/CriAssetSamples/Data/CueSheet_0.acb |
AWB Asset | /cri/unity/samples/UnityProject/Assets/CriAssetSamples/Data/CueSheet_0.awb |
Description of the program
Get the asset from the prefab list information via Addressables and display the corresponding buttons.
Get the prefab from the server and instantiate it by pressing the button in the window.
A CriAtomSourceForAsset is attached to each prefab, and the Cue Sheet is automatically loaded and the Cue played.
Initialization and modification of the catalog information
- After initializing the Addressables in CRI Addressables, call the function to modify the catalog information.
Call CriWare.Assets.CriAddressables.ModifyLocators once all the content catalogs have been loaded.
var catalogs = await Addressables.CheckForCatalogUpdates().Task;
if (catalogs.Count > 0)
await Addressables.UpdateCatalogs(catalogs).Task;
else
await Addressables.InitializeAsync().Task;
- Attention
- Note that even if CriWare.Assets.CriAddressables.ModifyLocators was not called,
it is still possible to access the contents. However, in this case, the functions returning the download size, such as Addressables.GetDownloadSizeAsync etc., will not work properly.
Instantiating a prefab containing CRI Assets
- The prefab instantiation is triggered via the button's click event corresponding to the prefab.
obj.GetComponentInChildren<
UnityEngine.UI.Button>().onClick.AddListener(() => {
Unload();
currentInfo = info;
info.prefab.InstantiateAsync().Completed += e => {
currentLoaded = e.Result;
UpdateView();
};
});
If the CRI asset has dependencies, the required resources are automatically retrieved as well via the Addressables.
The usual Addressables process is followed (with or without CRI assets).
The AssetBundle cache is disabled on some platforms following Unity specifications.
In this case, the CRIWARE data will be downloaded to a temporary area rather than to the cache.
Clearing the Cache
- If the instantiated prefab does not exist when the Clear Cache button is pressed, the cache will be deleted.
foreach (var info in prefabList.prefabs)
Addressables.ClearDependencyCacheAsync(info.prefab);
The Addressables API clears the actual data cache of the CRI assets in addition to the regular AssetBundle cache.
[Remarks]
For packages before Addressables 1.16.1,
the cache deletion of all Addressables content (including the resources of the CRI Asset) may not work properly.