Ejemplo n.º 1
0
        //----- method -----

        public SoundElement(SoundType type, SoundSheet soundSheet, CueInfo cueInfo, CriAtomExPlayback playback)
        {
            this.playback = playback;

            this.Type       = type;
            this.SoundSheet = soundSheet;
            this.CueInfo    = cueInfo;
        }
Ejemplo n.º 2
0
        private SoundSheet GetSoundSheet(CueInfo cueInfo)
        {
            if (cueInfo == null)
            {
                return(null);
            }

            var assetPath  = cueInfo.CueSheetPath;
            var soundSheet = managedSoundSheets.GetValueOrDefault(assetPath);

            if (soundSheet == null)
            {
                // パス情報生成.
                var acbPath = SoundSheet.AcbPath(assetPath);
                var awbPath = SoundSheet.AwbPath(assetPath);

                // ACBファイルのロード.
                CriAtomCueSheet cueSheet = null;

                try
                {
                    cueSheet = CriAtom.AddCueSheet(assetPath, acbPath, awbPath);
                }
                catch (Exception ex)
                {
                    Debug.LogException(ex);
                    return(null);
                }

                if (cueSheet.acb == null)
                {
                    return(null);
                }

                // ロードしたACBを保持した状態で再生成.
                soundSheet = new SoundSheet(assetPath, cueSheet.acb);

                managedSoundSheets.Add(soundSheet.AssetPath, soundSheet);

                var builder = new StringBuilder();

                builder.AppendFormat("Load : {0} : {1}", cueInfo.Cue, cueInfo.CueId).AppendLine();
                builder.AppendLine();
                builder.AppendFormat("Cue : {0}", cueInfo.Cue).AppendLine();
                builder.AppendFormat("CueId : {0}", cueInfo.CueId).AppendLine();
                builder.AppendFormat("FileName : {0}", Path.GetFileName(acbPath)).AppendLine();

                if (!string.IsNullOrEmpty(cueInfo.Summary))
                {
                    builder.AppendFormat("Summary: {0}", cueInfo.Summary).AppendLine();
                }

                UnityConsole.Event(ConsoleEventName, ConsoleEventColor, builder.ToString());
            }

            return(soundSheet);
        }
Ejemplo n.º 3
0
        private SoundSheet GetSoundSheet(CueInfo cueInfo)
        {
            if (cueInfo == null)
            {
                return(null);
            }

            var assetPath  = cueInfo.CueSheetPath;
            var soundSheet = managedSoundSheets.GetValueOrDefault(assetPath);

            if (soundSheet == null)
            {
                // パス情報生成.
                var acbPath = SoundSheet.AcbPath(assetPath);
                var awbPath = SoundSheet.AwbPath(assetPath);

                // ACBファイルのロード.
                CriAtomCueSheet cueSheet = null;

                try
                {
                    cueSheet = CriAtom.AddCueSheet(assetPath, acbPath, awbPath);
                }
                catch (Exception ex)
                {
                    Debug.LogException(ex);
                    return(null);
                }

                if (cueSheet.acb == null)
                {
                    return(null);
                }

                // ロードしたACBを保持した状態で再生成.
                soundSheet = new SoundSheet(assetPath, cueSheet.acb);

                managedSoundSheets.Add(soundSheet.AssetPath, soundSheet);

                UnityConsole.Event(ConsoleEventName, ConsoleEventColor, "Load : {0}", acbPath);
            }

            return(soundSheet);
        }
Ejemplo n.º 4
0
        private void ReleaseSoundSheet()
        {
            for (var i = 0; i < soundElements.Count; ++i)
            {
                if (!soundElements[i].FinishTime.HasValue)
                {
                    continue;
                }

                // 終了確認した時間から一定時間経過していたら解放.
                if (soundElements[i].FinishTime.Value + releaseTime < Time.realtimeSinceStartup)
                {
                    soundElements.RemoveAt(i);
                }
            }

            var targets = new List <SoundSheet>();

            foreach (var item in managedSoundSheets)
            {
                var release = true;

                // 再生中のCueが存在したら生存.
                foreach (var soundElement in soundElements)
                {
                    if (item.Key == soundElement.SoundSheet.AssetPath)
                    {
                        release = false;
                        break;
                    }
                }

                if (release)
                {
                    targets.Add(item.Value);
                }
            }

            foreach (var target in targets)
            {
                CriAtom.RemoveCueSheet(target.AssetPath);
                managedSoundSheets.Remove(target.AssetPath);
                UnityConsole.Event(ConsoleEventName, ConsoleEventColor, "UnLoad : {0}", SoundSheet.AcbPath(target.AssetPath));
            }
        }