generated from ayutaz/unity_template_repository
-
-
Notifications
You must be signed in to change notification settings - Fork 1
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 #29 from ayutaz/develop
v1.0
- Loading branch information
Showing
24 changed files
with
417 additions
and
167 deletions.
There are no files selected for viewing
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
File renamed without changes.
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,62 @@ | ||
using System.IO; | ||
using System.Linq; | ||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
public static class PackageExporter | ||
{ | ||
private const string RootDirectory = "Assets/KoeiromapUnity/Scripts"; | ||
private const string FileName = "KoeiromapUnity"; | ||
|
||
/// <summary> | ||
/// パッケージの書き出し(エディタ上でのテスト用) | ||
/// メニュー 「Tools > Export Unitypackage Test」をクリックで実行 | ||
/// </summary> | ||
[MenuItem("Tools/Export Unitypackage Test")] | ||
public static void ExportTestOnEditor() | ||
{ | ||
var exportPath = EditorUtility.SaveFilePanel | ||
( | ||
"保存先を選択", | ||
Application.dataPath, | ||
$"{FileName}.unitypackage", | ||
"unitypackage" | ||
); | ||
|
||
CreatePackage(RootDirectory, exportPath); | ||
} | ||
|
||
/// <summary> | ||
/// パッケージの書き出し | ||
/// GitHub Actionsから呼ばれる | ||
/// </summary> | ||
public static void Export() | ||
{ | ||
CreatePackage(RootDirectory, $"build/{FileName}.unitypackage"); | ||
} | ||
|
||
private static void CreatePackage(string rootDirectory, string exportPath) | ||
{ | ||
SafeCreateDirectory(exportPath); | ||
var assetsPaths = GetAllAssetsAtPath(rootDirectory); | ||
AssetDatabase.ExportPackage(assetsPaths, exportPath, ExportPackageOptions.Default); | ||
Debug.Log( | ||
$"Export complete: {Path.GetFullPath(exportPath)}\nExport below files:\n{string.Join("\n", assetsPaths)}"); | ||
} | ||
|
||
private static DirectoryInfo SafeCreateDirectory(string path) | ||
{ | ||
var diParent = Directory.GetParent(path); | ||
if (diParent == null || Directory.Exists(diParent.FullName)) return null; | ||
return Directory.CreateDirectory(diParent.FullName); | ||
} | ||
|
||
private static string[] GetAllAssetsAtPath(string root) | ||
{ | ||
return Directory.GetFiles(root, "*", SearchOption.AllDirectories) | ||
.Where(x => !string.IsNullOrEmpty(x)) | ||
.Where(x => !x.EndsWith(".meta")) | ||
.Where(x => x != ".DS_Store") | ||
.ToArray(); | ||
} | ||
} |
File renamed without changes.
This file was deleted.
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
Oops, something went wrong.