From 2f18ef67f2848457368eb2f05ddaed15be44cc73 Mon Sep 17 00:00:00 2001 From: yutopp Date: Mon, 7 Jan 2019 18:52:35 +0900 Subject: [PATCH] Support building test scenes for VRM.Samples --- .../DevOnly/Editor/VRMExportUnityPackage.cs | 33 +++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/Assets/VRM/UniVRM/DevOnly/Editor/VRMExportUnityPackage.cs b/Assets/VRM/UniVRM/DevOnly/Editor/VRMExportUnityPackage.cs index 1fc72c18c..e2c4fe02a 100644 --- a/Assets/VRM/UniVRM/DevOnly/Editor/VRMExportUnityPackage.cs +++ b/Assets/VRM/UniVRM/DevOnly/Editor/VRMExportUnityPackage.cs @@ -127,12 +127,16 @@ namespace VRM.DevOnly.PackageExporter Directory.CreateDirectory(folder); } - CreateUnityPackages(folder, true); + if (!BuildTestScene()) + { + Debug.LogError("Failed to build test scenes"); + } + CreateUnityPackages(folder); } public static void CreateUnityPackage() { - CreateUnityPackages(Path.GetFullPath(Path.Combine(Application.dataPath, "..")), false); + CreateUnityPackages(Path.GetFullPath(Path.Combine(Application.dataPath, ".."))); } static bool EndsWith(string path, params string[] exts) @@ -152,7 +156,7 @@ namespace VRM.DevOnly.PackageExporter return false; } - public static void CreateUnityPackages(string outputDir, bool build) + public static void CreateUnityPackages(string outputDir) { // UniVRM and sub packages { @@ -195,5 +199,28 @@ namespace VRM.DevOnly.PackageExporter var path = MakePackagePathName(outputDir, name); AssetDatabase.ExportPackage(targetFileNames, path, ExportPackageOptions.Default); } + + public static bool BuildTestScene() + { + var levels = new string[] { "Assets/VRM.Samples/Scenes/VRMRuntimeLoaderSample.unity" }; + return Build(levels); + } + + public static bool Build(string[] levels) + { + var buildPath = Path.GetFullPath(Application.dataPath + "/../build/build.exe"); + Debug.LogFormat("BuildPath: {0}", buildPath); + var build = BuildPipeline.BuildPlayer(levels, + buildPath, + BuildTarget.StandaloneWindows, + BuildOptions.None + ); +#if UNITY_2018_1_OR_NEWER + var isSuccess = build.summary.result != BuildResult.Succeeded; +#else + var isSuccess = !string.IsNullOrEmpty(build); +#endif + return isSuccess; + } } }