CRIWARE Unity Plugin Manual  Last Updated: 2024-07-12
Loading the data

Overview

The different ADX assets converted into Unity assets via CRI Assets can be loaded in two ways:
  • Loading from the script
  • Loading with component placed in a scene

Loading from the script

The assets can be used as any standard Unity asset.
To manage everything from scripts, it is possible to use the loading/unloading API defined for the asset.
For details, please refer to the reference manual of each asset class.
using System.Collections;
using CriWare;
public class AssetPlayback : MonoBehaviour
{
public CriAtomSourceBase AtomSource = null;
public CriAtomAcbAsset AcbAsset = null;
private IEnumerator LoadAndPlay()
{
AcbAsset.LoadAsync();
while (!AcbAsset.Loaded)
{
yield return null;
}
AtomSource.player.SetCue(AcbAsset.Handle, "CueName");
AtomSource.player.Start();
}
}

Loading with components placed in a scene

The CRI Atom Assets component can be used to explicitly load the ACF and ACB data.
Place it in the scene, and set the ACF and ACB to load in the Inspector.
addon4u_assetsupport_atomassets_load.png
Specifying ACF/ACB via CRI Atom Assets

Concerning the ACB, by placing component to play back CRI Assets (i.e., Cri Atom Source For Asset ) directly in the scene, playback can be performed without having to explicitly load the data.
If the ACB asset set in the Inspector was not loaded yet, this component will automatically load it before playback.
If this component is discarded after the loading, the ACB asset will be released automatically.
addon4u_assetsupport_atomsource_cue.png
Cue settings for "CRI Atom Source For Asset"
No component is mandatory. This auxiliary feature helps to load assets without writing a script.

Disabling the automatic loading
The automatic loading feature will be disabled when a function such as CriAtomAcbAsset.LoadAsync is used to load data before the automatic loading is triggered by CriAtomSourceForAsset.
The loading process is performed by the application code, and only the playback function of CriAtomSourceForAsset can be used.
Combined use of automatic loading and script loading
The CriAtomAssetsLoader class manages Cue Sheets thanks to the automatic loading via the components.
Use the CriAtomAssetsLoader API to combine automatic and script-based loading, in a way that is similar to the registration with the CriAtom class.
For details, please refer to the reference manual of the CriAtomAssetsLoader class.