private CriAtomExAcb LoadAcbFile(CriFsBinder binder, string acbFile, string awbFile) { if (String.IsNullOrEmpty(acbFile)) { return(null); } string acbPath = acbFile; if ((binder == null) && CriWare.Common.IsStreamingAssetsPath(acbPath)) { acbPath = Path.Combine(CriWare.Common.streamingAssetsPath, acbPath); } string awbPath = awbFile; if (!String.IsNullOrEmpty(awbPath)) { if ((binder == null) && CriWare.Common.IsStreamingAssetsPath(awbPath)) { awbPath = Path.Combine(CriWare.Common.streamingAssetsPath, awbPath); } } return(CriAtomExAcb.LoadAcbFile(binder, acbPath, awbPath)); }
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(); } }
public static CriAtomEx.CueInfo[] GetCueInfoList(CriAtomCueSheet cueSheet) { if (string.IsNullOrEmpty(cueSheet.name)) { return(null); } CriAtomEx.CueInfo[] result = null; while (!CriFsPlugin.isInitialized || !CriAtomPlugin.isInitialized) { Debug.Log("Sleep"); Thread.Sleep(1000); } try { var acb = CriAtomExAcb.LoadAcbFile(null, Path.Combine(Application.streamingAssetsPath, cueSheet.acbFile), Path.Combine(Application.streamingAssetsPath, cueSheet.awbFile)); if (acb != null) { result = acb.GetCueInfoList(); acb.Dispose(); } } catch (Exception e) { Debug.unityLogger.LogException(e); } return(result); }
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); } }
/* プレビュ用:音声データ設定・再生関数 */ private void StartPreviewPlayer() { if (isPreviewReady == false) { PreparePreview(); } if (isPreviewReady == true) { if (previewAcb == null || lastCuesheet != this.source.cueSheet) { if (previewAcb != null) { previewAcb.Dispose(); previewAcb = null; } foreach (var cuesheet in atomComponent.cueSheets) { if (cuesheet.name == this.source.cueSheet) { strPreviewAcb = Path.Combine(CriWare.streamingAssetsPath, cuesheet.acbFile); strPreviewAwb = (cuesheet.awbFile == null) ? null : Path.Combine(CriWare.streamingAssetsPath, cuesheet.awbFile); previewAcb = CriAtomExAcb.LoadAcbFile(null, strPreviewAcb, strPreviewAwb); lastCuesheet = cuesheet.name; } } } if (previewAcb != null) { if (previewPlayer != null) { previewPlayer.SetCue(previewAcb, this.source.cueName); previewPlayer.SetVolume(this.source.volume); previewPlayer.SetPitch(this.source.pitch); previewPlayer.Loop(this.source.loop); previewPlayer.Start(); } else { Debug.LogWarning("[CRIWARE] Player is not ready. Please try reloading the inspector"); } } else { Debug.LogWarning("[CRIWARE] Specified cue sheet could not be found"); } } }
private static CueInfo[] LoadAcbInfo(string path) { var result = new List <CueInfo>(); CriForceInitializer.Initialize(); var guids = AssetDatabase.FindAssets(string.Empty, new string[] { path }); var acbAssets = guids .Select(x => AssetDatabase.GUIDToAssetPath(x)) .Where(x => Path.GetExtension(x) == CriAssetDefinition.AcbExtension) .Select(x => AssetDatabase.LoadMainAssetAtPath(x)) .ToArray(); foreach (var acbAsset in acbAssets) { // 指定したACBファイル名(キューシート名)を指定してキュー情報を取得. var assetPath = AssetDatabase.GetAssetPath(acbAsset); var fullPath = UnityPathUtility.GetProjectFolderPath() + assetPath; var acb = CriAtomExAcb.LoadAcbFile(null, fullPath, ""); if (acb != null) { var cueInfos = acb.GetCueInfoList().ToArray(); foreach (var cueInfo in cueInfos) { var acbPath = assetPath.Replace(path + PathUtility.PathSeparator, string.Empty); acbPath = PathUtility.GetPathWithoutExtension(acbPath); result.Add(new CueInfo(cueInfo.name, acbPath, cueInfo.userData)); } acb.Dispose(); } } return(result.ToArray()); }
/* プレビュ用:音声データ設定・再生関数 */ private void StartPreviewPlayer() { if (previewPlayer == null) { return; } if (lastCuesheet != this.source.cueSheet) { if (previewAcb != null) { previewAcb.Dispose(); previewAcb = null; } foreach (var cuesheet in atomComponent.cueSheets) { if (cuesheet.name == this.source.cueSheet) { strPreviewAcb = Path.Combine(CriWare.Common.streamingAssetsPath, cuesheet.acbFile); strPreviewAwb = (cuesheet.awbFile == null) ? null : Path.Combine(CriWare.Common.streamingAssetsPath, cuesheet.awbFile); previewAcb = CriAtomExAcb.LoadAcbFile(null, strPreviewAcb, strPreviewAwb); lastCuesheet = cuesheet.name; } } } if (previewAcb != null) { previewPlayer.player.SetVolume(this.source.volume); previewPlayer.player.SetPitch(this.source.pitch); previewPlayer.player.Loop(this.source.loop); previewPlayer.Play(previewAcb, this.source.cueName); } else { Debug.LogWarning("[CRIWARE] Specified cue sheet could not be found"); } }
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); } }
public CriAtomExAcb GetAcb(string cueSheetName) { if (string.IsNullOrEmpty(cueSheetName)) { Debug.LogWarning("[CRIWARE] Timeline Previewer: cuesheet name is vacant"); return(null); } this.atom = (CriAtom)UnityEngine.Object.FindObjectOfType(typeof(CriAtom)); if (this.atom == null) { Debug.LogWarning("[CRIWARE] Timeline Previewer: CriAtom not set in the scene"); return(null); } if (lastAcfFile != this.atom.acfFile) { CriAtomEx.UnregisterAcf(); CriAtomEx.RegisterAcf(null, Path.Combine(CriWare.Common.streamingAssetsPath, atom.acfFile)); lastAcfFile = this.atom.acfFile; } if (this.acbTable.ContainsKey(cueSheetName)) { return(acbTable[cueSheetName]); } else { CriAtomExAcb acb = null; foreach (var cuesheet in atom.cueSheets) { if (cuesheet.name == cueSheetName) { string acbPath = (string.IsNullOrEmpty(cuesheet.acbFile)) ? null : Path.Combine(CriWare.Common.streamingAssetsPath, cuesheet.acbFile); string awbPath = (string.IsNullOrEmpty(cuesheet.awbFile)) ? null : Path.Combine(CriWare.Common.streamingAssetsPath, cuesheet.awbFile); acb = CriAtomExAcb.LoadAcbFile(null, acbPath, awbPath); if (acb != null) { try { acbTable.Add(cueSheetName, acb); } catch (Exception e) { if (e is ArgumentException) { /* impossible */ Debug.LogWarning("[CRIWARE] Timeline Previewer: ACB already existing."); } else { Debug.LogWarning("[CRIWARE] Timeline Previewer: ACB Dictionary exception: " + e.Message); } } } else { Debug.LogWarning("[CRIWARE] Timeline Previewer: Failed loading ACB/AWB file."); } } } return(acb); } }
private void GUICueList() { const int cCueListItemHeight = 18; var acbInfoList = projInfo.GetAcbInfoList(false, searchPath); if (isCueSheetListInitiated == true) { lastPreviewCueSheetId = this.selectedCueSheetId; } else { isCueSheetListInitiated = true; } EditorGUILayout.BeginHorizontal(); /* cuesheet list */ using (var cuesheetListScope = new EditorGUILayout.VerticalScope("CN Box", GUILayout.Width(200))) { using (var horizontalScope = new EditorGUILayout.HorizontalScope()) { if (GUILayout.Button("Cue Sheet", toolBarButtonStyle)) { projInfo.SortCueSheet(); this.selectedCueSheetId = 0; } } using (var cuesheetScrollViewScope = new EditorGUILayout.ScrollViewScope(scrollPosCueSheetList)) { scrollPosCueSheetList = cuesheetScrollViewScope.scrollPosition; int listLengthInView = (int)position.height / cCueListItemHeight; int idFirstItemInView = Mathf.Clamp((int)scrollPosCueSheetList.y / cCueListItemHeight, 0, Mathf.Max(0, acbInfoList.Count - listLengthInView)); GUILayout.Space(idFirstItemInView * cCueListItemHeight); for (int i = idFirstItemInView; i < Mathf.Min(idFirstItemInView + listLengthInView, acbInfoList.Count); i++) { GUI.color = (this.lastPreviewCueSheetId == i) ? Color.yellow : currentGuiColor; EditorGUILayout.BeginHorizontal(); if (GUILayout.Button(acbInfoList[i].name, EditorStyles.label)) { this.selectedCueSheetId = i; } EditorGUILayout.EndHorizontal(); } GUILayout.Space(Mathf.Max(0, acbInfoList.Count - idFirstItemInView - listLengthInView) * cCueListItemHeight); GUI.color = currentGuiColor; } } if (this.selectedCueSheetId != lastPreviewCueSheetId) { this.selectedCueInfoIndex = 0; } bool isCueSheetAvailable = (acbInfoList.Count > this.selectedCueSheetId); using (var cueListAndInfoScope = new EditorGUILayout.VerticalScope("CN Box")) { /* list title */ using (var cueListTitleScope = new EditorGUILayout.HorizontalScope()) { if (GUILayout.Button("Cue Name", toolBarButtonStyle)) { if (isCueSheetAvailable) { acbInfoList[selectedCueSheetId].SortCueInfo(CriAtomWindowInfo.CueSortType.Name); this.selectedCueInfoIndex = 0; } } if (GUILayout.Button("Cue ID", toolBarButtonStyle, GUILayout.Width(70))) { if (isCueSheetAvailable) { acbInfoList[selectedCueSheetId].SortCueInfo(CriAtomWindowInfo.CueSortType.Id); this.selectedCueInfoIndex = 0; } } } /* cue list */ bool playButtonPushed = false; bool isCueAvailable = false; CriAtomWindowInfo.CueInfo selectedCueInfo = null; using (var cueListScope = new EditorGUILayout.ScrollViewScope(scrollPosCueList, GUILayout.ExpandHeight(true))) { scrollPosCueList = cueListScope.scrollPosition; if (isCueSheetAvailable) { var acbInfo = acbInfoList[this.selectedCueSheetId]; List <CriAtomWindowInfo.CueInfo> currentList; if (this.showPrivateCue) { currentList = acbInfo.cueInfoList; } else { currentList = acbInfo.publicCueInfoList; } if (currentList.Count <= 0) { EditorGUILayout.HelpBox("Nothing to be shown here.\nTry push the \"Reload Info\" button to refresh the list.", MessageType.Error); } else { int listLengthInView = (int)position.height / cCueListItemHeight; int idFirstCueInView = Mathf.Clamp((int)scrollPosCueList.y / cCueListItemHeight, 0, Mathf.Max(0, currentList.Count - listLengthInView)); GUILayout.Space(idFirstCueInView * cCueListItemHeight); for (int i = idFirstCueInView; i < Mathf.Min(idFirstCueInView + listLengthInView, currentList.Count); ++i) { GUI.color = (this.selectedCueInfoIndex == i) ? Color.yellow : currentGuiColor; using (var cueItemScope = new EditorGUILayout.HorizontalScope(GUILayout.Height(cCueListItemHeight))) { if (GUILayout.Button(EditorGUIUtility.IconContent("Animation.Play"), EditorStyles.miniButton, GUILayout.Width(30))) { this.selectedCueInfoIndex = i; playButtonPushed = true; } if (GUILayout.Button(currentList[i].name, EditorStyles.label)) { if (selectedCueInfoIndex != i) { StopPreview(); } this.selectedCueInfoIndex = i; } GUILayout.Label(currentList[i].id.ToString(), GUILayout.Width(40)); } } GUILayout.Space(Mathf.Max(0, currentList.Count - idFirstCueInView - listLengthInView) * cCueListItemHeight); GUI.color = currentGuiColor; } isCueAvailable = currentList.Count > this.selectedCueInfoIndex; if (isCueAvailable) { selectedCueInfo = currentList[selectedCueInfoIndex]; } } else { EditorGUILayout.HelpBox("No cue sheet is found.\nPlease check the search path. Press \"Reload Info\" button to refresh the list.", MessageType.Info); } } if (playButtonPushed) { if (isCueSheetAvailable && isCueAvailable) { StopPreview(); var acbInfo = acbInfoList[selectedCueSheetId]; TryInitializePlugin(); if (lastAcbName != acbInfo.name) { if (previewAcb != null) { previewAcb.Dispose(); } previewAcb = CriAtomExAcb.LoadAcbFile( null, Path.Combine(CriWare.Common.streamingAssetsPath, acbInfo.acbPath), string.IsNullOrEmpty(acbInfo.awbPath) ? null : Path.Combine(CriWare.Common.streamingAssetsPath, acbInfo.awbPath) ); lastAcbName = acbInfo.name; } if (previewAcb != null) { PlayPreview(previewAcb, selectedCueInfo.name); } } } EditorGUILayout.BeginHorizontal("AppToolbar"); { EditorGUILayout.LabelField("Cue Information"); EditorGUILayout.Space(); { var tempToggleVal = GUILayout.Toggle(this.showPrivateCue, "Show Private Cue", EditorStyles.toolbarButton, GUILayout.Width(150)); if (tempToggleVal != this.showPrivateCue) { /* Clear cue selection when change setting */ this.selectedCueInfoIndex = 0; } this.showPrivateCue = tempToggleVal; } if (GUILayout.Button("Stop All", EditorStyles.toolbarButton, GUILayout.Width(100))) { StopPreview(); } } EditorGUILayout.EndHorizontal(); EditorGUILayout.LabelField("Cue ID", (isCueSheetAvailable && isCueAvailable) ? selectedCueInfo.id.ToString() : "N/A"); string cueName = "N/A"; string userData = ""; if (isCueSheetAvailable && isCueAvailable) { cueName = selectedCueInfo.name; userData = selectedCueInfo.comment; } EditorGUILayout.LabelField("Cue Name", cueName); EditorGUILayout.LabelField("User Data", userData, EditorStyles.wordWrappedLabel, GUILayout.Height(28)); /* edit buttons */ GUIEdit(); } /* cueListAndInfoScope */ EditorGUILayout.EndHorizontal(); }