public string FileNameToPath(string fileName, string LocalizeDir) { if (string.IsNullOrEmpty(fileName)) { return(fileName); } string path; /* //既に絶対URLならそのまま * if (FilePathUtil.IsAbsoluteUri(fileName)) * { * path = fileName; * } * else*/ { try { //拡張子がなければデフォルト拡張子を追加 if (string.IsNullOrEmpty(FilePathUtil.GetExtension(fileName))) { fileName += defaultExt; } path = defaultDir + LocalizeDir + "/" + fileName; } catch (System.Exception e) { Debug.LogError(fileName + " " + e.ToString()); path = defaultDir + LocalizeDir + "/" + fileName; } } if (legacyAutoChangeSoundExt) { //プラットフォームが対応する拡張子にする(mp3とoggを入れ替え) //ファイルを直接使う場合は必要だった処理だが、デバッグログでも拡張子が変わって混乱ケースがあるので廃止 return(ExtensionUtil.ChangeSoundExt(path)); } else { return(path); } }
//ストレージタイプを解析 AssetFileStrageType ParseStrageType() { //URLならWeb系の if (FilePathUtil.IsAbsoluteUri(FilePath)) { #if UNITY_WEBPLAYER || UNITY_WEBGL return(AssetFileStrageType.WebNocache); #else return(AssetFileStrageType.Web); #endif } else if (Setting.IsStreamingAssets) { return(AssetFileStrageType.StreamingAssets); } else { return(AssetFileStrageType.Resources); } }
protected virtual bool TryReadSaveData() { if (DontUseSystemSaveData) { return(false); } string saveDir = FilePathUtil.Combine(FileIOManager.SdkPersistentDataPath, DirectoryName); //セーブデータのディレクトリがなければ作成 FileIOManager.CreateDirectory(saveDir); Path = FilePathUtil.Combine(saveDir, FileName); if (!FileIOManager.Exists(Path)) { return(false); } return(FileIOManager.ReadBinaryDecode(Path, ReadBinary)); }
/// <summary> /// ラベルからファイルパスを取得 /// </summary> /// <param name="label">ラベル</param> /// <returns>ファイルパス</returns> public bool ContainsLabel(string label) { //既に絶対URLならそのまま if (FilePathUtil.IsAbsoluteUri(label)) { return(true); } else { AdvTextureSettingData data = FindData(label); if (data == null) { return(false); } else { return(true); } } }
//ログファイルを書き込む void WriteManifestLog(AssetBundleManifest manifest, string outputPath) { System.Text.StringBuilder builder = new System.Text.StringBuilder(); foreach (string assetBundleName in manifest.GetAllAssetBundles()) { builder.Append(assetBundleName); builder.AppendLine(); Hash128 hash = manifest.GetAssetBundleHash(assetBundleName); builder.AppendFormat(" Hash128: {1}", assetBundleName, hash.ToString()); builder.AppendLine(); builder.AppendLine(); } string logFilePath = FilePathUtil.Combine(outputPath, Path.GetFileNameWithoutExtension(outputPath)); logFilePath += ExtensionUtil.Log + ExtensionUtil.Txt; File.WriteAllText(logFilePath, builder.ToString()); }
public void LoadInitFileList(int version) { string dir = ResourceDir; bool useConvertFileList = ResourceLoadType == LoadType.Server ? useConvertFileListOnServer : useConvertFileListOnLocal; bool useAssetBundleFileList = ResourceLoadType == LoadType.Server ? useAssetBundleListOnServer : useAssetBundleListOnLocal; List <string> pathList = new List <string>(); if (useConvertFileList) { string path = FilePathUtil.Combine(dir, FilePathUtil.GetDirectoryNameOnly(ResourceDir + "/") + ExtensionUtil.ConvertFileList); pathList.Add(path); } if (useAssetBundleFileList) { string AssetBundleTarget = AssetBundleHelper.RuntimeAssetBundleTraget().ToString(); string assetBundlePath = FilePathUtil.Combine(AssetBundleTarget, AssetBundleTarget + ExtensionUtil.ConvertFileList); string path = FilePathUtil.Combine(dir, assetBundlePath); pathList.Add(path); } AssetFileManager.LoadInitFileList(pathList, version); }
//実際にロードするパスを設定 protected virtual string ParseLoadPath() { switch (FileInfo.StrageType) { case AssetFileStrageType.Server: case AssetFileStrageType.StreamingAssets: { if (this.FileInfo.AssetBundleInfo == null) { Debug.LogError("Not found in assetbundle list " + FileName); return(FilePathUtil.EncodeUrl(FileName)); } string url = this.FileInfo.AssetBundleInfo.Url; url = FilePathUtil.ToCacheClearUrl(url); return(FilePathUtil.EncodeUrl(url)); } case AssetFileStrageType.Resources: default: return(FileName); } }
/// <summary> /// ラベルからファイルパスを取得 /// </summary> /// <param name="label">ラベル</param> /// <param name="type">サウンドのタイプ</param> /// <returns>ファイルパス</returns> public string LabelToFilePath(string label, SoundType type) { //既に絶対URLならそのまま if (FilePathUtil.IsAbsoluteUri(label)) { //プラットフォームが対応する拡張子にする return(ExtensionUtil.ChangeSoundExt(label)); } else { AdvSoundSettingData data = FindData(label); if (data == null) { //ラベルをそのままファイル名扱いに return(label); } else { return(data.FilePath); } } }
/* * /// <summary> * /// 指定のキャラ名の立ち絵があるか * /// </summary> * /// <param name="name">キャラ名</param> * /// <param name="label">ラベル</param> * /// <returns>ファイルパス</returns> * public bool Contains(string name, string label) * { * if (!defaultKey.ContainsKey(name)) * { * return false; * } * else * { * string key = ToDataKey(name, label); * return this.ContainsKey(key); * } * } */ /* * /// <summary> * /// キャラのデフォルトファイルパスを取得 * /// </summary> * /// <param name="name">キャラ名</param> * /// <returns>ファイルパス</returns> * public string GetDefaultPath(string name ) * { * if (!defaultKey.ContainsKey(name)) * { * Debug.LogError("Not found default texture :" + name ); * return ""; * } * string key = defaultKey.Get(name); * return FindData(key).FilePath; * } */ /* * /// <summary> * /// ラベルからテクスチャ情報を取得 * /// </summary> * /// <param name="label">ラベル</param> * /// <returns>スプライト情報</returns> * public GraphicInfo LabelToTextureInfo(string name, string label) * { * //既に絶対URLならそのまま * if (UtageToolKit.IsAbsoluteUri(label)) * { * //ラベルをそのままファイル名扱いに * return new GraphicInfo(label); * } * else * { * string key = ToFileKey(name, label); * AdvCharacterSettingData data = FindData(key); * if (data == null) * { * //名前をキーに * data = FindData(ToFileKey(name, "")); * if( data == null ) * { * //ラベルをそのままファイル名扱いに * return new GraphicInfo(label); * } * else * { * return data.GraphicInfo; * } * } * else * { * return data.GraphicInfo; * } * } * } */ /// <summary> /// キーからグラフィック情報を取得 /// </summary> /// <param name="label">ラベル</param> /// <returns>スプライト情報</returns> public GraphicInfoList KeyToGraphicInfo(string key) { //既に絶対URLならそのまま if (FilePathUtil.IsAbsoluteUri(key)) { //ラベルをそのままファイル名扱いに return(new GraphicInfoList(key)); } else { AdvCharacterSettingData data = FindData(key); if (data == null) { //ラベルをそのままファイル名扱いに return(new GraphicInfoList(key)); } else { return(data.Graphic); } } }
//アセットバンドルマニフェストを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(); } } )); }
/// <summary> /// ファイル名をパスに /// </summary> /// <param name="fileName">ファイル名</param> /// <returns>ファイルパス</returns> public string ScenaioFileToPath(string scenaioFile) { //既に絶対URLならそのまま if (FilePathUtil.IsAbsoluteUri(scenaioFile)) { return(scenaioFile); } else { //拡張子がなければデフォルト拡張子を追加 if (string.IsNullOrEmpty(FilePathUtil.GetExtension(scenaioFile))) { scenaioFile += defaultExt; } //旧形式(ファイル分割なし)に対応 if (!scenaioFile.Contains("/")) { scenaioFile = "Scenario/" + scenaioFile; } return(FilePathUtil.Combine(defaultDir, scenaioFile)); } }
//コンバートファイルリストのファイルを読み込む void Read() { //出力先のアセットバンドル情報を読み込む string convertFileListPath = FilePathUtil.Combine(OutputResourcesPath, Path.GetFileNameWithoutExtension(OutputResourcesPath) + ExtensionUtil.ConvertFileList); bool isEncoded = Settings.FindSettingFromPath(convertFileListPath).EncodeType == AssetFileEncodeType.AlreadyEncoded; if (isEncoded) { convertFileListPath += ExtensionUtil.UtageFile; } ConvertFileList = new ConvertFileList(convertFileListPath); //ファイルから読み込む if (File.Exists(convertFileListPath)) { byte[] bytes = File.ReadAllBytes(convertFileListPath); if (isEncoded) { bytes = FileIOManager.Decode(bytes); } BinaryUtil.BinaryRead(bytes, ConvertFileList.Read); } }
public static void Write(string path, StringGridDictionary gridDictionary) { /* string ext = Path.GetExtension (path); * switch (ext) * { * case ExtXls: * book = new HSSFWorkbook(); * break; * case ExtXlsx: * book = new XSSFWorkbook(); * break; * default: * break; * } */ path = FilePathUtil.ChangeExtension(path, ExtXls); IWorkbook book = MakeBook(gridDictionary); using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write)) { book.Write(fs); } }
//ファイルのパスから、ファイル情報を取得 public bool TryGetValue(string filePath, AssetFileEncodeType encodeType, out ConvertFileInfo info) { info = null; switch (encodeType) { case AssetFileEncodeType.AlreadyEncoded: if (!FilePathUtil.IsUnderDirectory(filePath, DirectoryPath)) { return(false); } string fileKey = FilePathUtil.RemoveDirectory(filePath, DirectoryPath); foreach (var files in FileLists.Values) { if (files.TryGetValue(fileKey, out info)) { return(true); } } return(false); case AssetFileEncodeType.AssetBundle: string assetName = FilePathUtil.GetFileNameWithoutExtension(filePath).ToLower(); string keyPlatform = AssetBundleHelper.RuntimeAssetBundleTraget().ToString(); ConvertFileInfoDictionary infoList; if (FileLists.TryGetValue(keyPlatform, out infoList)) { if (infoList.TryGetValue(assetName, out info)) { return(true); } } return(false); default: return(false); } }
//アセットバンドルマニフェストをDLして情報を追加 public IEnumerator DownloadManifestAsync(string rootUrl, string relativeUrl, Action onComplete, Action onFailed) { string url = FilePathUtil.Combine(rootUrl, relativeUrl); url = FilePathUtil.ToCacheClearUrl(url); WWWEx wwwEx = new WWWEx(url); if (UseCacheManifest) { wwwEx.IoManager = FileIOManager; wwwEx.WriteLocal = true; wwwEx.WritePath = GetCachePath(relativeUrl); } 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 (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(); }
//章別に分かれたシナリオをロードする IEnumerator LoadChaptersAsync(string rootDir) { //動的に作成 AdvImportScenarios scenarios = ScriptableObject.CreateInstance <AdvImportScenarios>(); foreach (string chapterName in ChapterNames) { string url = FilePathUtil.Combine(rootDir, chapterName) + ".chapter.asset"; AssetFile file = AssetFileManager.Load(url, this); while (!file.IsLoadEnd) { yield return(null); } AdvChapterData chapter = file.UnityObject as AdvChapterData; if (scenarios == null) { Debug.LogError(url + " is not scenario file"); yield break; } scenarios.AddChapter(chapter); } this.Scenarios = scenarios; }
//キャッシュのパスを取得 string GetCachePath(string relativeUrl) { string path = FilePathUtil.Combine(FileIOManager.SdkTemporaryCachePath, cacheDirectoryName, relativeUrl); return(path); }
string ToStreamingPath(string path) { return(FilePathUtil.Combine((Application.platform == RuntimePlatform.Android) ? "" : "file://", Application.streamingAssetsPath, path)); }
void InitDefaultDirInfo(string root, DefaultDirInfo info) { info.defaultDir = FilePathUtil.Combine(root, info.defaultDir); }
string ToDirPath() { return(FilePathUtil.Combine(FileIOManager.SdkPersistentDataPath, DirectoryName + "/")); }
//キャッシュすべて削除 public void DeleteAllCache() { FileIOManager.DeleteDirectory(FilePathUtil.Combine(FileIOManager.SdkTemporaryCachePath, cacheDirectoryName) + "/"); UnityEngine.Caching.ClearCache(); }
Sprite2D CreateSprite(GraphicInfoList graphic) { GraphicInfo texture = graphic.Main; Sprite2D sprite = UtageToolKit.AddChildGameObjectComponent <Sprite2D>(this.transform, FilePathUtil.GetFileNameWithoutExtension(texture.File.FileName)); sprite.SetTextureFile(texture, PixelsToUnits); sprite.LocalOrderInLayer = Layer.SettingData.Order; return(sprite); }
/// <summary> /// 既にその章データを設定済みか /// </summary> /// <param name="url">パス</param> public bool ExitsChapter(string url) { string chapterAssetName = FilePathUtil.GetFileNameWithoutExtension(url); return(DataManager.SettingDataManager.ImportedScenarios.Chapters.Exists(x => x.name == chapterAssetName)); }
//マクロ処理したインポートデータを作成する 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); } }
void InitDefaultDirInfo(string root, DefaultDirInfo info, string betweenDir = "") { info.defaultDir = FilePathUtil.Combine(root, betweenDir, info.defaultDir); }
internal AssetFileUtageManager(AssetFileManager assetFileManager) { AssetFileManager = assetFileManager; CacheRootDir = FilePathUtil.Combine(FileIOManager.SdkTemporaryCachePath, AssetFileManager.cacheDirectoryName); CacheTblPath = FilePathUtil.Combine(FileIOManager.SdkTemporaryCachePath, AssetFileManager.cacheTblFileName); }
//キャッシュすべて削除 public void DeleteAllCache() { FileIOManager.DeleteDirectory(FilePathUtil.Combine(FileIOManager.SdkTemporaryCachePath, cacheDirectoryName) + "/"); WrapperUnityVersion.CleanCache(); }
public void DeleteAllCache() { string[] args = new string[] { FileIOManagerBase.SdkTemporaryCachePath, this.cacheDirectoryName }; this.FileIOManager.DeleteDirectory(FilePathUtil.Combine(args) + "/"); WrapperUnityVersion.CleanCache(); }
string ToFilePath(string id) { return(FilePathUtil.Combine(ToDirPath(), FileName + id)); }