Skip to content

Commit

Permalink
Merge pull request #35 from azarashi2931/ci-test
Browse files Browse the repository at this point in the history
ビルド時に言語ファイルが自動でコピーされるようにPostBuildProcessを追加
  • Loading branch information
azrsh authored Apr 3, 2020
2 parents 239b9eb + b7eb4f4 commit 0d8af08
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Assets/Editor/BuildProcessor.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 51 additions & 0 deletions Assets/Editor/BuildProcessor/LanguageFileProcessor.cs
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 Assets/Editor/BuildProcessor/LanguageFileProcessor.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0d8af08

Please sign in to comment.