Support building test scenes for VRM.Samples

This commit is contained in:
yutopp
2019-01-07 18:52:35 +09:00
parent 409c745981
commit 2f18ef67f2

View File

@@ -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;
}
}
}