mackysoft c53f01ce99 Packaging Update
# Added
- Added LICENCE.
- Added build workflow.
- Added release workflow.
- Added PackageTools.

# Changed
- Update Unity from 2020.3.1f1 to 2020.8.1f1.
2021-05-14 01:34:02 +09:00

56 lines
1.5 KiB
C#

using System.IO;
using System.Linq;
using UnityEngine;
using UnityEditor;
namespace MackySoft.PackageTools.Editor {
public static class UnityPackageExporter {
// The name of the unitypackage to output.
const string k_PackageName = "SerializeReference-Extensions";
// The path to the package under the `Assets/` folder.
const string k_PackagePath = "MackySoft";
// Path to export to.
const string k_ExportPath = "Build";
const string k_SearchPattern = "*";
const string k_PackageToolsFolderName = "PackageTools";
const string k_ResourcesFolderName = "Resources";
[MenuItem("Tools/SerializeReference Extensions/Export Package")]
public static void Export () {
ExportPackage($"{k_ExportPath}/{k_PackageName}.unitypackage");
}
public static string ExportPackage (string exportPath) {
// Ensure export path.
var dir = new FileInfo(exportPath).Directory;
if (dir != null && !dir.Exists) {
dir.Create();
}
// Export
AssetDatabase.ExportPackage(
GetAssetPaths(),
exportPath,
ExportPackageOptions.Default
);
return Path.GetFullPath(exportPath);
}
public static string[] GetAssetPaths () {
var path = Path.Combine(Application.dataPath,k_PackagePath);
var assets = Directory.EnumerateFiles(path,k_SearchPattern,SearchOption.AllDirectories)
.Where(x => !x.Contains(k_PackageToolsFolderName) && !x.Contains(k_ResourcesFolderName))
.Select(x => "Assets" + x.Replace(Application.dataPath,"").Replace(@"\","/"))
.ToArray();
return assets;
}
}
}