mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-08-23 11:05:29 -05:00
move VRMExportUnityPackage to UniVRMTest
This commit is contained in:
@@ -1,112 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
#if UNITY_2018_1_OR_NEWER
|
||||
using UnityEditor.Build.Reporting;
|
||||
#endif
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace VRM
|
||||
{
|
||||
public static class VRMExportUnityPackage
|
||||
{
|
||||
static string GetDesktop()
|
||||
{
|
||||
return Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "/VRM";
|
||||
}
|
||||
|
||||
const string DATE_FORMAT = "yyyyMMdd";
|
||||
const string PREFIX = "UniVRM";
|
||||
|
||||
static string GetPath(string prefix)
|
||||
{
|
||||
var folder = GetDesktop();
|
||||
if (!Directory.Exists(folder))
|
||||
{
|
||||
Directory.CreateDirectory(folder);
|
||||
}
|
||||
|
||||
//var date = DateTime.Today.ToString(DATE_FORMAT);
|
||||
|
||||
var path = string.Format("{0}/{1}-{2}.unitypackage",
|
||||
folder,
|
||||
prefix,
|
||||
VRMVersion.VERSION
|
||||
).Replace("\\", "/");
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
static IEnumerable<string> EnumerateFiles(string path)
|
||||
{
|
||||
if (Path.GetFileName(path).StartsWith(".git"))
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
if (Directory.Exists(path))
|
||||
{
|
||||
foreach(var child in Directory.GetFileSystemEntries(path))
|
||||
{
|
||||
foreach(var x in EnumerateFiles(child))
|
||||
{
|
||||
yield return x;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Path.GetExtension(path).ToLower() != ".meta")
|
||||
{
|
||||
yield return path.Replace("\\", "/");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if VRM_DEVELOP
|
||||
[MenuItem("VRM/Export unitypackage")]
|
||||
#endif
|
||||
public static void CreateUnityPackage()
|
||||
{
|
||||
// まずビルドする
|
||||
var levels = new string[] { "Assets/VRM/_RuntimeLoaderSample/VRMRuntimeLoaderSample.unity" };
|
||||
var buildPath = Path.GetFullPath(Application.dataPath + "/../build/build.exe");
|
||||
Debug.LogFormat("{0}", buildPath);
|
||||
var build=BuildPipeline.BuildPlayer(levels,
|
||||
buildPath,
|
||||
BuildTarget.StandaloneWindows,
|
||||
BuildOptions.None
|
||||
);
|
||||
#if UNITY_2018_1_OR_NEWER
|
||||
var iSuccess = build.summary.result != BuildResult.Succeeded;
|
||||
#else
|
||||
var iSuccess = !string.IsNullOrEmpty(build);
|
||||
#endif
|
||||
|
||||
var path = GetPath(PREFIX);
|
||||
if (File.Exists(path))
|
||||
{
|
||||
Debug.LogErrorFormat("{0} is already exists", path);
|
||||
return;
|
||||
}
|
||||
|
||||
var files = EnumerateFiles("Assets/VRM")
|
||||
.ToArray();
|
||||
|
||||
// 本体
|
||||
AssetDatabase.ExportPackage(files
|
||||
.Where(x => !x.StartsWith("Assets/VRM/_RuntimeLoaderSample/")).ToArray()
|
||||
, path, ExportPackageOptions.Interactive);
|
||||
|
||||
// サンプル
|
||||
AssetDatabase.ExportPackage(files
|
||||
.Where(x => x.StartsWith("Assets/VRM/_RuntimeLoaderSample/")).ToArray()
|
||||
, GetPath(PREFIX+"-RuntimeLoaderSample"), ExportPackageOptions.Interactive);
|
||||
|
||||
Debug.LogFormat("exported: {0}", path);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6895a43269f0daf4eab06931c9a7724c
|
||||
timeCreated: 1521714822
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user