-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from azarashi2931/ci-test
ビルド時に言語ファイルが自動でコピーされるようにPostBuildProcessを追加
- Loading branch information
Showing
3 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System.IO; | ||
using UnityEngine; | ||
using UnityEditor.Build; | ||
using UnityEditor.Build.Reporting; | ||
|
||
public class LanguageFileProcessor : IPostprocessBuildWithReport | ||
{ | ||
public void OnPostprocessBuild(BuildReport report) | ||
{ | ||
var directoryPath = Application.dataPath + "/Languages"; | ||
var outputPath = report.summary.outputPath; | ||
var nextPath = Path.GetDirectoryName(outputPath) + "/" + Path.GetFileNameWithoutExtension(outputPath) + "_data/Languages"; | ||
|
||
Debug.Log("Copy" + directoryPath + "To" + nextPath); | ||
|
||
CopyDirectory(directoryPath, nextPath); | ||
|
||
var metaFiles = Directory.GetFiles(nextPath, "*.meta", SearchOption.AllDirectories); | ||
foreach (var item in metaFiles) | ||
File.Delete(item); | ||
} | ||
|
||
// 実行順 | ||
public int callbackOrder { get { return 0; } } | ||
|
||
|
||
static void CopyDirectory(string sourceDirectoryName, string targetDirectoryName) | ||
{ | ||
DirectoryInfo source = new DirectoryInfo(sourceDirectoryName); | ||
|
||
if (!source.Exists) | ||
return; | ||
|
||
if (!Directory.Exists(targetDirectoryName)) | ||
Directory.CreateDirectory(targetDirectoryName); | ||
|
||
FileInfo[] files = source.GetFiles(); | ||
foreach (FileInfo file in files) | ||
{ | ||
string temppath = Path.Combine(targetDirectoryName, file.Name); | ||
file.CopyTo(temppath, false); | ||
} | ||
|
||
DirectoryInfo[] subDirectories = source.GetDirectories(); | ||
foreach (DirectoryInfo subDirectory in subDirectories) | ||
{ | ||
string temppath = Path.Combine(targetDirectoryName, subDirectory.Name); | ||
CopyDirectory(subDirectory.FullName, temppath); | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Assets/Editor/BuildProcessor/LanguageFileProcessor.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.