Skip to content

Commit

Permalink
feat: package exporter
Browse files Browse the repository at this point in the history
  • Loading branch information
kyubuns committed Feb 3, 2021
1 parent 073b20e commit 6fd43b2
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions Assets/Editor/PackageExporter.cs
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;
}
}

0 comments on commit 6fd43b2

Please sign in to comment.