using UnityEngine; public class ExampleScript : MonoBehaviour { /* 各キャラクタのボイスを再生するためのプレーヤ */ public CriAtomSource[] atomSources; /* 各キャラクタ用のサウンドオブジェクト */ private CriAtomExSoundObject[] soundObjects; void Start () { int numSources = atomSources.Length; soundObjects = new CriAtomExSoundObject[numSources]; for (int i = 0; i < numSources; i++) { /* カテゴリキューリミットスコープを有効にしてサウンドオブジェクトを作成 */ soundObjects[i] = new CriAtomExSoundObject(false, true); /* プレーヤをサウンドオブジェクトに設定 */ soundObjects[i].AddPlayer(atomSources[i].player); } } void OnDestroy() { for (int i = 0; i < soundObjects.Length; i++) { soundObjects[i].DeleteAllPlayers(); soundObjects[i].Dispose(); } } }