//ファイルの書き込み internal void Write(string folderPath) { string path = FilePathUtil.Combine(folderPath, this.Path + ExtensionUtil.TSV); string dir = FilePathUtil.GetDirectoryPath(path); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } // ファイルにテキストを書き出し。 File.WriteAllText(path, this.Grid.ToText()); }
///アセットバンドルをロード IEnumerator LoadAssetBundleAsync(Action <UnityWebRequest, AssetBundle> onComplete, Action <UnityWebRequest> onFailed) { return(LoadAsync( //OnComplete (www) => { AssetBundle assetBundle = null; if (WriteLocal) { IoManager.CreateDirectory(FilePathUtil.GetDirectoryPath(WritePath) + "/"); IoManager.Write(WritePath, www.downloadHandler.data); assetBundle = AssetBundle.LoadFromFile(WritePath); } else { assetBundle = DownloadHandlerAssetBundle.GetContent(www); } if (assetBundle != null) { //成功! if (onComplete != null) { onComplete(www, assetBundle); } } else { //失敗 if (!IgnoreDebugLog) { Debug.LogError(www.url + " is not assetBundle"); } if (onFailed != null) { onFailed(www); } } }, //OnFailed (www) => { //失敗 if (onFailed != null) { onFailed(www); } } )); }
public void CreateScenariosIfMissing() { if (this.scenarios != null) { return; } string path = AssetDatabase.GetAssetPath(this); path = FilePathUtil.Combine(FilePathUtil.GetDirectoryPath(path), ProjectName + ".scenarios.asset"); //設定データのアセットをロードまたは作成 this.scenarios = UtageEditorToolKit.GetImportedAssetCreateIfMissing <AdvImportScenarios>(path); this.scenarios.hideFlags = HideFlags.NotEditable; EditorUtility.SetDirty(this); }
//アセットバンドルマニフェストをDLして情報を追加 public IEnumerator DownloadManifestAsync(string rootUrl, string relativeUrl, Action onComplete, Action onFailed) { string url = FilePathUtil.Combine(rootUrl, relativeUrl); url = DLCManager.CreateDLCUrlForUtage(url); //url = FilePathUtil.ToVersionManagerUrl(url); WWWEx wwwEx = new WWWEx(url); wwwEx.StoreBytes = true; wwwEx.OnUpdate = OnDownloadingManifest; wwwEx.RetryCount = retryCount; wwwEx.TimeOut = timeOut; // Debug.Log("Load Start " + url); return(wwwEx.LoadAssetBundleByNameAsync <AssetBundleManifest>( AssetBundleManifestName, false, (manifest) => { AddAssetBundleManifest(rootUrl, manifest); if (UseCacheManifest) { string path = GetCachePath(relativeUrl); FileIOManager.CreateDirectory(FilePathUtil.GetDirectoryPath(path) + "/"); FileIOManager.Write(path, wwwEx.Bytes); } if (onComplete != null) { onComplete(); } }, () => { if (onFailed != null) { onFailed(); } } )); }
//ファイルのコンバート void Build(bool isRebuild, DicingFolderData folderData) { MainAssetInfo inut = new MainAssetInfo(folderData.InputFolder); MainAssetInfo output1 = new MainAssetInfo(folderData.OuputFolder1); MainAssetInfo output2 = new MainAssetInfo(folderData.OuputFolder2); foreach (var child in inut.GetAllChildren()) { //ディレクトリのみ検索 if (!child.IsDirectory) { continue; } //子以下のフォルダは対象にしない if (FilePathUtil.GetDirectoryPath(child.AssetPath) != inut.AssetPath) { continue; } Build(child, output1, output2, isRebuild); } AssetDatabase.Refresh(); }
//マクロ処理したインポートデータを作成する void ImportChapter(string chapterName, List <AdvImportBook> books) { //チャプターデータを作成し、各シナリオを設定 string path = AssetDatabase.GetAssetPath(this.Project); path = FilePathUtil.Combine(FilePathUtil.GetDirectoryPath(path), chapterName); AdvChapterData chapter = LoadOrCreateChapterAsset(path); this.scenariosAsset.AddChapter(chapter); //初期化 chapter.ImportBooks(books, this.macroManager); //設定データの解析とインポート AdvSettingDataManager setting = new AdvSettingDataManager(); setting.ImportedScenarios = this.scenariosAsset; setting.BootInit(""); chapter.MakeScenarioImportData(setting, this.macroManager); EditorUtility.SetDirty(chapter); AdvGraphicInfo.CallbackExpression = setting.DefaultParam.CalcExpressionBoolean; TextParser.CallbackCalcExpression = setting.DefaultParam.CalcExpressionNotSetParam; iTweenData.CallbackGetValue = setting.DefaultParam.GetParameter; List <AdvScenarioData> scenarioList = new List <AdvScenarioData>(); foreach (var book in books) { foreach (var grid in book.ImportGridList) { grid.InitLink(); string sheetName = grid.SheetName; if (!AdvSheetParser.IsScenarioSheet(sheetName)) { continue; } if (scenarioDataTbl.ContainsKey(sheetName)) { Debug.LogError(sheetName + " is already contains in the sheets"); } else { AdvScenarioData scenario = new AdvScenarioData(grid); scenarioDataTbl.Add(sheetName, scenario); scenarioList.Add(scenario); } } } //シナリオデータとして解析、初期化 foreach (AdvScenarioData data in scenarioList) { data.Init(setting); } AdvGraphicInfo.CallbackExpression = null; TextParser.CallbackCalcExpression = null; iTweenData.CallbackGetValue = null; //シナリオラベルのリンクチェック ErrorCheckScenarioLabel(scenarioList); //文字数カウント if (Project.CheckTextCount) { CheckCharacterCount(scenarioList); } }
public ConvertFileList(string filePath) { FilePath = filePath; DirectoryPath = FilePathUtil.GetDirectoryPath(filePath); FileLists = new Dictionary <string, ConvertFileInfoDictionary>(); }
//**************************** TSVのロード用 ****************************// /// <summary> /// TSVをロード /// </summary> /// <param name="url">ファイルパス</param> /// <param name="version">シナリオバージョン(-1以下で必ずサーバーからデータを読み直す)</param> /// <returns></returns> internal IEnumerator CoLoadFromTsv(string url, int version) { //起動ファイルの読み込み AssetFile bootFile = AssetFileManager.Load(url, version, this); Debug.Log("Load Chapter : " + ChapterName + " :Ver " + bootFile.Version); while (!bootFile.IsLoadEnd) { yield return(null); } string rootDir = FilePathUtil.GetDirectoryPath(url); //設定ファイルの読み込み List <AssetFile> settingFileList = new List <AssetFile>(); { StringGrid grid = bootFile.Csv; foreach (StringGridRow row in grid.Rows) { if (row.RowIndex < grid.DataTopRow) { continue; //データの行じゃない } if (row.IsEmptyOrCommantOut) { continue; //データがない } string path = AdvParser.ParseCell <string>(row, AdvColumnName.Param1); int ver = AdvParser.ParseCell <int>(row, AdvColumnName.Version); settingFileList.Add(AssetFileManager.Load(FilePathUtil.Combine(rootDir, path), ver, this)); } } //設定ファイルの読み込み List <AssetFile> scenarioFileList = new List <AssetFile>(); foreach (var item in settingFileList) { while (!item.IsLoadEnd) { yield return(null); } if (!item.IsLoadError) { StringGrid grid = item.Csv; if (grid.SheetName != AdvSheetParser.SheetNameScenario) { this.RuntimeGridList.Add(grid); } else { foreach (StringGridRow row in grid.Rows) { if (row.RowIndex < grid.DataTopRow) { continue; //データの行じゃない } if (row.IsEmptyOrCommantOut) { continue; //データがない } string path = AdvParser.ParseCell <string>(row, AdvColumnName.FileName); int ver = AdvParser.ParseCellOptional <int>(row, AdvColumnName.Version, 0); //旧形式(ファイル分割なし)に対応 if (!path.Contains("/")) { path = "Scenario/" + path; } path += ".tsv"; scenarioFileList.Add(AssetFileManager.Load(FilePathUtil.Combine(rootDir, path), ver, this)); } } } item.Unuse(this); } foreach (var item in scenarioFileList) { while (!item.IsLoadEnd) { yield return(null); } if (!item.IsLoadError) { this.RuntimeGridList.Add(item.Csv); } item.Unuse(this); } bootFile.Unuse(this); // Debug.Log("Load End Chapter : " + url + " :Ver " + bootFile.Version); Debug.Log("Load End Chapter : " + ChapterName + " :Ver " + bootFile.Version); }
///WWWを使ったロード処理 IEnumerator LoadAsyncSub(Action <WWW> onComplete, Action <WWW> onFailed, Action <WWW> onTimeOut, int retryCount) { #if !UTAGE_DISABLE_CACHING if (LoadType == Type.Cache) { while (!Caching.ready) { yield return(null); } } #endif bool retry = false; //WWWでダウンロード using (WWW www = CreateWWW()) { float time = 0; bool isTimeOut = false; this.Progress = 0; //ロード待ち while (!www.isDone && !isTimeOut) { //タイムアウトチェック if (0 < TimeOut) { if (Progress == www.progress) { time += Time.deltaTime; if (time >= TimeOut) { isTimeOut = true; } } else { time = 0; } } Progress = www.progress; if (OnUpdate != null) { OnUpdate(this); } yield return(null); } if (isTimeOut) { //タイムアウト if (retryCount <= 0) { if (onTimeOut != null) { onTimeOut(www); } } else { retry = true; } } else if (!string.IsNullOrEmpty(www.error)) { //ロードエラー if (retryCount <= 0) { if (onFailed != null) { onFailed(www); } } else { retry = true; } } else { Progress = www.progress; if (WriteLocal) { IoManager.CreateDirectory(FilePathUtil.GetDirectoryPath(WritePath) + "/"); IoManager.Write(WritePath, www.bytes); } else if (OnUpdate != null) { OnUpdate(this); } //ロード終了 if (onComplete != null) { onComplete(www); } } } //リトライするなら再帰で呼び出す if (retry) { yield return(LoadAsyncSub(onComplete, onFailed, onTimeOut, retryCount - 1)); } }