Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Santarh committed Mar 27, 2024
1 parent c5b4166 commit 5138290
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 17 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/create-unitypackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ jobs:
create-unitypackage:
needs: [detect-unity-version, run-edit-mode-tests]
runs-on: [self-hosted, Windows, X64, Unity]
timeout-minutes: 10
timeout-minutes: 20
steps:
- name: Create UnityPackage
id: create-unitypackage
Expand All @@ -103,6 +103,7 @@ jobs:
-projectPath "${UNITY_PROJECT_PATH}" \
-executeMethod "VRM.DevOnly.PackageExporter.VRMExportUnityPackage.CreateUnityPackageWithBuild" \
-logFile create-unitypackage.log
- name: Upload UnityPackage
uses: actions/upload-artifact@v4
with:
Expand Down
40 changes: 24 additions & 16 deletions Assets/VRM/Editor/VRMExportUnityPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public static bool EndsWithAndMeta(this string str, string terminator)
}
}

/// <summary>
/// TODO: 本来このクラスは「パッケージとしての UniVRM」のスコープのクラスであるが、「UPM Package VRM」のスコープにコードがあるので変
/// </summary>
public static class VRMExportUnityPackage
{
static string GetProjectRoot()
Expand Down Expand Up @@ -142,18 +145,20 @@ public static void CreateUnityPackageWithBuild()
{
try
{
Debug.Log($"[{nameof(VRMExportUnityPackage)}] Start CreateUnityPackageWithBuild...");
var folder = GetProjectRoot();
if (!Directory.Exists(folder))
{
Directory.CreateDirectory(folder);
}

if (!BuildTestScene())
{
throw new Exception("Failed to build test scenes");
}
Debug.Log($"[{nameof(VRMExportUnityPackage)}] Try to build test scenes...");
BuildTestScene();

Debug.Log($"[{nameof(VRMExportUnityPackage)}] Create UnityPackages...");
CreateUnityPackages(folder);

Debug.Log($"[{nameof(VRMExportUnityPackage)}] Finish CreateUnityPackageWithBuild");
if (Application.isBatchMode)
{
EditorApplication.Exit(0);
Expand Down Expand Up @@ -201,7 +206,7 @@ public PackageInfo(string name)
}
}

public static void CreateUnityPackages(string outputDir)
private static void CreateUnityPackages(string outputDir)
{
if (!VRMSampleCopy.Validate())
{
Expand Down Expand Up @@ -250,7 +255,7 @@ public static void CreateUnityPackages(string outputDir)
}
}

public static void CreateUnityPackage(
private static void CreateUnityPackage(
string outputDir,
PackageInfo package
)
Expand All @@ -264,13 +269,18 @@ PackageInfo package
AssetDatabase.ExportPackage(targetFileNames, path, ExportPackageOptions.Default);
}

public static bool BuildTestScene()
private static void BuildTestScene()
{
var levels = new string[] { "Assets/VRM.Samples/Scenes/VRMRuntimeLoaderSample.unity" };
return Build(levels);
var levels = new string[]
{
"Assets/UniGLTF_Samples/GltfViewer/GltfViewer.unity",
"Assets/VRM_Samples/SimpleViewer/SimpleViewer.unity",
"Assets/VRM10_Samples/VRM10Viewer/VRM10Viewer.unity",
};
Build(levels);
}

public static bool Build(string[] levels)
private static void Build(string[] levels)
{
var buildPath = Path.GetFullPath(Application.dataPath + "/../build/build.exe");
Debug.LogFormat("BuildPath: {0}", buildPath);
Expand All @@ -279,12 +289,10 @@ public static bool Build(string[] levels)
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;
if (build.summary.result != BuildResult.Succeeded)
{
throw new Exception("Failed to build scenes");
}
}
}
}

0 comments on commit 5138290

Please sign in to comment.