private void LoadCueInfo(UnityEngine.Object acbAsset) { cueInfos = new List <CueInfo>(); // 指定したACBファイル名(キューシート名)を指定してキュー情報を取得. var assetPath = AssetDatabase.GetAssetPath(acbAsset); var fullPath = UnityPathUtility.GetProjectFolderPath() + assetPath; var acb = CriAtomExAcb.LoadAcbFile(null, fullPath, ""); if (acb != null) { var list = acb.GetCueInfoList(); foreach (var item in list) { var path = PathUtility.GetPathWithoutExtension(assetPath); var cueInfo = new CueInfo(string.Empty, path, item.name, item.userData); cueInfos.Add(cueInfo); } acb.Dispose(); } }
private void GetAcbInfoListCore(string searchPath, ref int acbIndex) { string[] files = System.IO.Directory.GetFiles(searchPath); foreach (string file in files) { if (System.IO.Path.GetExtension(file.Replace("\\", "/")) == ".acb") { AcbInfo acbInfo = new AcbInfo(System.IO.Path.GetFileNameWithoutExtension(file), acbIndex, "", System.IO.Path.GetFileName(file), "", ""); /* 指定したACBファイル名(キューシート名)を指定してキュー情報を取得 */ CriAtomExAcb acb = CriAtomExAcb.LoadAcbFile(null, file.Replace("\\", "/"), ""); if (acb != null) { /* キュー名リストの作成 */ CriAtomEx.CueInfo[] cueInfoList = acb.GetCueInfoList(); foreach (CriAtomEx.CueInfo cueInfo in cueInfoList) { CueInfo tmpCueInfo = new CueInfo(cueInfo.name, cueInfo.id, cueInfo.userData); bool found = false; foreach (var key in acbInfo.cueInfoList) { if (key.id == cueInfo.id) { found = true; break; } } if (found == false) { acbInfo.cueInfoList.Add(tmpCueInfo); } else { // inGame時のサブシーケンスの場合あり //Debug.Log("already exists in the dictionay id:" + cueInfo.id.ToString() +"name:" + cueInfo.name); } } acb.Dispose(); } else { Debug.Log("GetAcbInfoList LoadAcbFile. acb is null. " + file); } tmpAcbInfoList.Add(acbInfo); acbIndex++; } } // directory string[] directories = System.IO.Directory.GetDirectories(searchPath); foreach (string directory in directories) { GetAcbInfoListCore(directory, ref acbIndex); } }
} /* end of class */ #endregion public static bool GetCueInfo(bool forceReload) { if (CriAtomAcfInfo.acfInfo == null || forceReload) { GetCueInfoInternal(); } /* もしACFInfoが無い場合、acfがあるか検索 */ if (CriAtomAcfInfo.acfInfo == null) { //Debug.LogWarning("ADX2 need \"CriAtomProjInfo_Unity.cs\""); string[] files = System.IO.Directory.GetFiles(Application.streamingAssetsPath); int acbIndex = 0; foreach (string file in files) { if (System.IO.Path.GetExtension(file.Replace("\\", "/")) == ".acf") { CriAtomAcfInfo.acfInfo = new AcfInfo(System.IO.Path.GetFileNameWithoutExtension(file), 0, "", System.IO.Path.GetFileName(file), "", ""); } } if (CriAtomAcfInfo.acfInfo != null) { foreach (string file in files) { if (System.IO.Path.GetExtension(file.Replace("\\", "/")) == ".acb") { AcbInfo acbInfo = new AcbInfo(System.IO.Path.GetFileNameWithoutExtension(file), acbIndex, "", System.IO.Path.GetFileName(file), "", ""); /* 指定したACBファイル名(キューシート名)を指定してキュー情報を取得 */ //CriAtomExAcb acb = CriAtomExAcb.LoadAcbFile(null, file.Replace("\\","/"), ""); /* キュー名リストの作成 */ //int cueIndex = 0; //CriAtomEx.CueInfo[] cueInfoList = acb.GetCueInfoList(); //foreach(CriAtomEx.CueInfo cueInfo in cueInfoList){ // CueInfo tmpCueInfo = new CueInfo(cueInfo.name,cueInfo.id,""); // acbInfo.cueInfoList.Add(cueIndex,tmpCueInfo); //} CueInfo tmpCueInfo = new CueInfo("DummyCue", 0, ""); acbInfo.cueInfoList.Add(0, tmpCueInfo); CriAtomAcfInfo.acfInfo.acbInfoList.Add(acbInfo); acbIndex++; } } } } return(CriAtomAcfInfo.acfInfo != null); }
void btnAdd_Click(object sender, System.EventArgs e) { if (txtCategory.Text != "" && txtFilepath.Text != "" && txtName.Text != "") { CueInfo cue = new CueInfo() { CategoryName = txtCategory.Text, Name = txtName.Text, Filepath = txtFilepath.Text, Volume = StringHelper.FloatFromString(txtVolume.Text), Loop = StringHelper.BoolFromString((string)cboLoops.SelectedItem), SingleInstance = StringHelper.BoolFromString((string)cboSingle.SelectedItem) }; if (!jjaxFile.SoundCategories.Contains(txtCategory.Text)) { jjaxFile.SoundCategories.Add(txtCategory.Text); lstCate.Items.Add(txtCategory.Text); } else if ((string)lstCate.SelectedItem == txtCategory.Text) { lstCue.Items.Add(cue.Name); } bool exists = false; int i = 0; while (!exists && i < jjaxFile.Info.Count) { if (jjaxFile.Info[i].Name == txtName.Text) { jjaxFile.Info.Remove(jjaxFile.Info[i]); exists = true; } i++; } jjaxFile.Info.Add(cue); } else { MessageBox.Show("All feilds must be filled."); } }
static JJaxCategory GetCategory(string name) { CueInfo info = (from c in cueInfos where c.Name == name select c).FirstOrDefault(); if (info != null) { JJaxCategory cat = (from c in categories where c.Name == info.CategoryName select c).FirstOrDefault(); return(cat); } return(null); }
public override IEnumerator LoadAsync(Action onComplete, Action onFailed) { if (string.IsNullOrEmpty(resourcesPath)) { onFailed(); yield break; } var updateYield = ExternalResources.UpdateAsset(resourcesPath).ToYieldInstruction(false); yield return(updateYield); if (updateYield.HasError) { onFailed(); yield break; } if (Priority != AssetFileLoadPriority.DownloadOnly) { var cueYield = ExternalResources.GetCueInfo(resourcesPath, soundName).ToYieldInstruction(); while (!cueYield.IsDone) { yield return(null); } CueInfo = cueYield.Result; if (CueInfo == null) { IsLoadError = true; onFailed(); yield break; } } IsLoadEnd = true; onComplete(); }
void lstCue_SelectedIndexChanged(object sender, System.EventArgs e) { if (lstCue.SelectedIndex != -1) { CueInfo c = null; for (int i = 0; i < jjaxFile.Info.Count; i++) { if (jjaxFile.Info[i].Name == (string)lstCue.SelectedItem) { c = jjaxFile.Info[i]; } } if (c != null) { if (c.Loop) { cboLoops.SelectedIndex = 0; } else { cboLoops.SelectedIndex = 1; } if (c.SingleInstance) { cboSingle.SelectedIndex = 0; } else { cboSingle.SelectedIndex = 1; } txtCategory.Text = c.CategoryName; txtName.Text = c.Name; txtVolume.Text = "" + c.Volume; txtFilepath.Text = c.Filepath; } } }
void OnBeat(int beatID) { while (m_cueInfos.Count > 0 && m_cueInfos[0].initBeat == beatID) { CueInfo info = m_cueInfos[0]; m_cueInfos.RemoveAt(0); m_cueSignals[(int)info.instrument].ReInit(this, m_audioManager, m_metronome, info); } foreach (var cue in m_cueSignals) { cue.OnBeat(beatID); } // Hack for getting instruments to start playing on correct beat. if (beatID == 16) { m_cueSignals[(int)Instrument.violas_lead].StartAnimation(); m_cueSignals[(int)Instrument.violins_lead].StartAnimation(); m_cueSignals[(int)Instrument.bass].StartAnimation(); } }
/// <summary> /// Plays a sound that sounds like it's being played in 3D space. /// </summary> /// <param name="soundName">The name of the sound.</param> /// <param name="position">The position of the sound.</param> public static void PlaySound3D(string soundName, Vector3 position) { if (soundName != null) { if (GetTotalBeingPlayed() <= 60) { CueInfo info = (from c in cueInfos where c.Name == soundName select c).FirstOrDefault(); if (info != null) { if (!info.SingleInstance || (info.SingleInstance && !IsPlaying(soundName))) { JJaxCue song; if (position != Vector3.Zero) { song = new JJaxCue(info, position); } else { song = new JJaxCue(info); } JJaxCategory cate = GetCategory(soundName); cate.Play(song); } } else { throw new ArgumentNullException("Sound dosn't exist " + soundName); } } } }
private void GetAcbInfoListCore(string searchPath) { acbInfoList.Clear(); string[] files = null; try { files = Directory.GetFiles(searchPath, "*.acb", SearchOption.AllDirectories); } catch (Exception ex) { if (ex is ArgumentException || ex is ArgumentNullException) { Debug.LogWarning("[CRIWARE] Insufficient search path. Please check the path for file searching."); } else if (ex is DirectoryNotFoundException) { Debug.LogWarning("[CRIWARE] Search path not found: " + searchPath); } else { Debug.LogError("[CRIWARE] Error getting ACB files. Message: " + ex.Message); } } if (files == null) { return; } int acbIndex = 0; foreach (string file in files) { AcbInfo acbInfo = new AcbInfo( Path.GetFileNameWithoutExtension(file), acbIndex++, "", TryGetRelFilePath(file), TryGetAwbFile(file)); /* 指定したACBファイル名(キューシート名)を指定してキュー情報を取得 */ string acbFilePath = file.Replace("\\", "/"); CriAtomExAcb acb = CriAtomExAcb.LoadAcbFile(null, acbFilePath, ""); if (acb != null) { acbInfo.assetGuid = AssetDatabase.AssetPathToGUID("Assets" + acbFilePath.Substring(Application.dataPath.Length)); /* キュー名リストの作成 */ CriAtomEx.CueInfo[] cueInfoList = acb.GetCueInfoList(); foreach (CriAtomEx.CueInfo cueInfo in cueInfoList) { bool found = false; foreach (var key in acbInfo.cueInfoList) { if (key.id == cueInfo.id) { found = true; break; } } if (found == false) { var newCueInfo = new CueInfo(cueInfo.name, cueInfo.id, cueInfo.userData, Convert.ToBoolean(cueInfo.headerVisibility)); acbInfo.cueInfoList.Add(newCueInfo); if (newCueInfo.isPublic) { acbInfo.publicCueInfoList.Add(newCueInfo); } } else { /* inGame時のサブシーケンスの場合あり */ Debug.Log("[CRIWARE] Duplicate cue ID " + cueInfo.id.ToString() + " in cue sheet " + acbInfo.name + ". Last cue name:" + cueInfo.name); } } acb.Dispose(); } else { Debug.Log("[CRIWARE] Failed to load ACB file: " + file); } acbInfoList.Add(acbInfo); } }
} /* end of class */ #endregion public static bool GetCueInfo(bool forceReload) { if (CriAtomAcfInfo.acfInfo == null || forceReload) { GetCueInfoInternal(); } /* もしACFInfoが無い場合、acfがあるか検索 */ if (CriAtomAcfInfo.acfInfo == null) { //Debug.LogWarning("ADX2 need \"CriAtomProjInfo_Unity.cs\""); string[] files = System.IO.Directory.GetFiles(Application.streamingAssetsPath); int acbIndex = 0; foreach (string file in files) { if (System.IO.Path.GetExtension(file.Replace("\\","/")) == ".acf") { CriAtomAcfInfo.acfInfo = new AcfInfo(System.IO.Path.GetFileNameWithoutExtension(file), 0,"",System.IO.Path.GetFileName(file),"",""); } } if(CriAtomAcfInfo.acfInfo != null){ foreach (string file in files) { if (System.IO.Path.GetExtension(file.Replace("\\","/")) == ".acb") { AcbInfo acbInfo = new AcbInfo(System.IO.Path.GetFileNameWithoutExtension(file), acbIndex,"",System.IO.Path.GetFileName(file),"",""); /* 指定したACBファイル名(キューシート名)を指定してキュー情報を取得 */ //CriAtomExAcb acb = CriAtomExAcb.LoadAcbFile(null, file.Replace("\\","/"), ""); /* キュー名リストの作成 */ //int cueIndex = 0; //CriAtomEx.CueInfo[] cueInfoList = acb.GetCueInfoList(); //foreach(CriAtomEx.CueInfo cueInfo in cueInfoList){ // CueInfo tmpCueInfo = new CueInfo(cueInfo.name,cueInfo.id,""); // acbInfo.cueInfoList.Add(cueIndex,tmpCueInfo); //} CueInfo tmpCueInfo = new CueInfo("DummyCue",0,""); acbInfo.cueInfoList.Add(0,tmpCueInfo); CriAtomAcfInfo.acfInfo.acbInfoList.Add(acbInfo); acbIndex++; } } } } return (CriAtomAcfInfo.acfInfo != null); }