void LoadDiffTexOnBasePath(string basePath) { string jsonPath = ""; if (File.Exists(basePath + "Option.json")) { jsonPath = basePath + "Option.json"; } else if (Directory.Exists(basePath + "RiClothesSetuper/")) { jsonPath = basePath + "RiClothesSetuper/" + "Option.json"; } V1.ExpandOption expandOption = FileUtil.LoadJsonFile <V1.ExpandOption>(jsonPath); V1DiffTextGen = new V1.DiffTexGeneratorProcess(expandOption.difference_textures, basePath); }
/* * ExpandOptionを読み込む (バージョンごとに読み込み処理を変える) * 先にLoadExpandFileVersionを実行してバージョンを取得して置かないと動かない */ private void LoadExpandOption() { V1ExpandOptionProcess = null; V2ExpandOptionProcess = null; if (expandOptionVersion == null) { return; } switch (expandOptionVersion.version) { case 1: V1.ExpandOption v1ExpandOption = FileUtil.LoadJsonFile <V1.ExpandOption>(expandJsonPath); if (v1ExpandOption != null) { //V1のExpandOption内で使用されるパスのベースは服のプレハブがあるベースのフォルダになる V1ExpandOptionProcess = new V1.ExpandOptionProcess(v1ExpandOption, clothPrefabParentPath); } break; case 2: V2.ExpandOption v2ExpandOption = FileUtil.LoadJsonFile <V2.ExpandOption>(expandJsonPath); if (v2ExpandOption != null) { //V2のExpandOption内で使用されるパスのベースはそのJSONファイルがあるフォルダになる V2ExpandOptionProcess = new V2.ExpandOptionProcess(v2ExpandOption, Path.GetDirectoryName(expandJsonPath) + "/"); } break; default: Debug.Log("非対応のバージョンです"); isUnsupportedVersion = true; break; } }
void LoadDiffTexture() { ClearDiffTexture(); if (PrefabData.GetCloth() == null) { return; } clothPrefabParentPath = PrefabUtility.GetPrefabAssetPathOfNearestInstanceRoot(PrefabData.GetCloth()); if (clothPrefabParentPath == "") { return; } string basePath = FileUtil.GetBasePath().Replace("Assets/", "") + Path.GetDirectoryName(clothPrefabParentPath) + "/"; OptionPath optionPath = OptionPath.LoadOptionPathFromBaseDir(basePath); TryLoadV2(basePath, optionPath); //V2の読み込みができていたら終了 if (V2DiffTextGen != null) { return; } //プレハブ直下もしくは"RiClothesSetuper/" にOptionPathのjsonファイルを置くパターン if (optionPath != null) { //DiffText V1の読み込み if (optionPath.option_json_path != null && optionPath.option_json_path != "") { string optionJsonPath = ""; optionJsonPath = FileUtil.GetPathFromRelative(basePath, optionPath.option_json_path); V1.ExpandOption expandOption = FileUtil.LoadJsonFile <V1.ExpandOption>(optionJsonPath); string outputPath = basePath; if (optionPath.base_path != null && optionPath.base_path != "") { outputPath = FileUtil.GetPathFromRelative(basePath, optionPath.base_path); } if (expandOption != null) { V1DiffTextGen = new V1.DiffTexGeneratorProcess(expandOption.difference_textures, outputPath); } } else if (optionPath.base_path != null && optionPath.base_path != "") { string optionBasePath = FileUtil.GetPathFromRelative(basePath, optionPath.base_path); LoadDiffTexOnBasePath(optionBasePath); } } //この時点でロードできていたら終了 if (V1DiffTextGen != null) { return; } //プレハブ直下もしくは"RiClothesSetuper/"にOption.jsonを置くパターン if (clothPrefabParentPath != "") { LoadDiffTexOnBasePath(basePath); } }