-
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
17 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,30 @@ | ||
using System.IO; | ||
using System; | ||
using System.IO; | ||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
namespace Development | ||
{ | ||
public static class PackageExporter | ||
{ | ||
[MenuItem("Dev/Export Package")] | ||
private const string Target = "Assets/AnimeTask"; | ||
|
||
[MenuItem("Export/Package")] | ||
public static void Export() | ||
{ | ||
var directories = new[] | ||
{ | ||
"Assets/AnimeTask", | ||
}; | ||
|
||
// ReSharper disable once AssignNullToNotNullAttribute | ||
var outputPath = Path.Combine(Path.GetDirectoryName(Application.dataPath), "AnimeTask.unitypackage"); | ||
|
||
AssetDatabase.ExportPackage(directories, outputPath, ExportPackageOptions.Recurse); | ||
var packageText = AssetDatabase.LoadAssetAtPath<TextAsset>(Path.Combine(Target, "package.json")); | ||
var package = JsonUtility.FromJson<PackageJson>(packageText.text); | ||
|
||
var outputPath = Path.Combine(Path.GetDirectoryName(Application.dataPath) ?? "", $"{package.displayName}_v{package.version}.unitypackage"); | ||
AssetDatabase.ExportPackage(new[] { Target }, outputPath, ExportPackageOptions.Recurse); | ||
Debug.LogFormat("ExportPackage {0}", outputPath); | ||
} | ||
} | ||
} | ||
|
||
[Serializable] | ||
public class PackageJson | ||
{ | ||
public string displayName; | ||
public string version; | ||
} | ||
} |