| ミドルウェア | CRI ADX2 (CRI Atom) | 補足 |
| サンプル | Basicサンプル | |
| 格納場所 | /cri/unity/samples/UnityProject/Assets/Scenes/criatom/basic/ | |
| シーンファイル | Scene_07_Ingame_Pinball.unity | |
| スクリプトファイル | Scene_07_Ingame_Pinball_PlayBounce.cs | 物理コリジョン判定時に音を再生させるスクリプトです。 SoundManagerの関数を呼び出します。 |
| スクリプトファイル | Scene_07_Ingame_Pinball_SoundManager.cs | サウンド処理を管理するスクリプトです。 |
| ACFファイル | Pinball.acf | |
| ACBファイル | PinballMain.acb |
/* Get the Cue info by specifying the ACB file name (CueSheet name). */ CriAtomExAcb acb = CriAtom.GetAcb(cueSheetName); /* Create a list of Cue names. */ CriAtomEx.CueInfo[] cueInfoList = acb.GetCueInfoList(); foreach(CriAtomEx.CueInfo cueInfo in cueInfoList){ cueNameList.Add(cueInfo.name); }
/* AtomSource for bouncing sound */ private CriAtomSource atomSourceBounce = null; /* AtomSource for BGM */ private CriAtomSource atomSourceBGM = null; (省略) /* Create the CriAtomSource for bouncing sound. */ atomSourceBounce = gameObject.AddComponent<CriAtomSource>(); atomSourceBounce.cueSheet = cueSheetName; atomSourceBounce.cueName = cueNameList[(int)enumCueNameList.wood + seNo]; /* Create the CriAtomSource for BGM. */ atomSourceBGM = gameObject.AddComponent<CriAtomSource>(); atomSourceBGM.cueSheet = cueSheetName; atomSourceBGM.cueName = cueNameList[(int)enumCueNameList.bgm0 + bgmNo];
/* Bouncing sound */ public void PlayBounce() { /* Specify a Cue name. */ atomSourceBounce.cueName = cueNameList[(int)enumCueNameList.wood + seNo]; /* Play */ atomSourceBounce.Play(); }
#region Variables private Scene_07_Ingame_Pinball_SoundManager soundManager = null; #endregion #region Functions void Start() { /* Get the SoundManager. */ soundManager = FindObjectOfType(typeof(Scene_07_Ingame_Pinball_SoundManager)) as Scene_07_Ingame_Pinball_SoundManager; } /* Play at collision. */ void OnTriggerEnter(Collider other) { /* Play at collision hit. */ soundManager.PlayBounce(); /* If BGM is stopped, restore it. */ soundManager.ResumeBGM(); } #endregion
public void ResumeBGM() { /* Play when in the PLAYEND or in the STOP. */ /* (Automatically restore at the time of ACB update) */ CriAtomSource.Status status = atomSourceBGM.status; if ((status == CriAtomSource.Status.Stop) || (status == CriAtomSource.Status.PlayEnd)) { /* Play */ PlayBGM(); /* Change the volume of category [main]. */ CriAtom.SetCategoryVolume("main", mainVolume); /* Add the feature of level monitor for in-game preview. */ CriAtom.SetBusAnalyzer(true); } }