diff --git a/.github/workflows/build-webgl.yml b/.github/workflows/build-webgl.yml index 4adaae47a..cfaaac27e 100644 --- a/.github/workflows/build-webgl.yml +++ b/.github/workflows/build-webgl.yml @@ -2,6 +2,9 @@ name: WebGL to gh-page on: workflow_dispatch: + # push: + # branches: + # - workflow-webgl-wip env: UNITY_PROJECT_PATH: . @@ -53,17 +56,47 @@ jobs: echo "${UNITY_EDITOR_EXECUTABLE} is installed." echo "unity-editor-executable=${UNITY_EDITOR_EXECUTABLE}" >> "${GITHUB_OUTPUT}" - - name: Buidl WebGL - id: build-webgl + # URP + - name: Build VRM10Viewer + id: build-webgl-VRM10Viewer run: | - # build to Build/SimpleViewer + # build to Build/VRM10Viewer "${{ steps.detect-unity-version.outputs.unity-editor-executable }}" \ - -batchmode \ + -batchmode -quit \ -silent-crashes \ -projectPath "${{ env.UNITY_PROJECT_PATH }}" \ - -executeMethod "VRM.BuildClass.BuildWebGL_SimpleViewer" \ - -logFile create-webgl.log - echo "Success to create BuildWebGL." + -executeMethod "UniVRM10.DevOnly.BuildClass.BuildWebGL_VRM10Viewer" \ + -logFile webgl-VRM10Viewer.log + echo "Success to WebGL VRM10Viewer." + + # はじめに built-in RenderPipeline にして一度終わる。然るのちに + - name: Build SimpleViewer + id: build-webgl-SimpleViewer + run: | + "${{ steps.detect-unity-version.outputs.unity-editor-executable }}" \ + -batchmode -quit \ + -silent-crashes \ + -projectPath "${{ env.UNITY_PROJECT_PATH }}" \ + -executeMethod "VRM.DevOnly.BuildClass.SwitchBuiltinPipeline" + echo "Success to Switch built-in RenderPipeline." + + # build to Build/SimpleViewer + "${{ steps.detect-unity-version.outputs.unity-editor-executable }}" \ + -batchmode -quit \ + -silent-crashes \ + -projectPath "${{ env.UNITY_PROJECT_PATH }}" \ + -executeMethod "VRM.DevOnly.BuildClass.BuildWebGL_SimpleViewer" \ + -logFile webgl-SimpleViewer.log + echo "Success to WebGL SimpleViewer." + + # make index + cat << __HTML__ > Build/index.html +

$GITHUB_SHA

+ + __HTML__ - name: Upload artifact uses: actions/upload-pages-artifact@v2 diff --git a/Assets/VRM/Editor/BuildClass.cs b/Assets/VRM/Editor/BuildClass.cs index 410de15a4..cff6d56ff 100644 --- a/Assets/VRM/Editor/BuildClass.cs +++ b/Assets/VRM/Editor/BuildClass.cs @@ -1,7 +1,6 @@ using UnityEditor; -using UnityEngine.Rendering; -namespace VRM +namespace VRM.DevOnly { public static class BuildClass { @@ -27,6 +26,11 @@ namespace VRM } } + public static void SwitchBuiltinPipeline() + { + UnityEngine.Rendering.GraphicsSettings.renderPipelineAsset = null; + } + public static void BuildWebGL_SimpleViewer() { var scenes = new string[]{ @@ -46,25 +50,5 @@ namespace VRM throw new System.Exception(report.summary.ToString()); } } - - public static void BuildWebGL_VRM10Viewer() - { - var scenes = new string[]{ - "./Assets/VRM10_Samples/VRM10Viewer/VRM10Viewer.unity", - }; - - var report = BuildPipeline.BuildPlayer(new BuildPlayerOptions - { - scenes = scenes, - locationPathName = "Build/VRM10Viewer", - target = BuildTarget.WebGL, - } - ); - - if (report.summary.result != UnityEditor.Build.Reporting.BuildResult.Succeeded) - { - throw new System.Exception(report.summary.ToString()); - } - } } } diff --git a/Assets/VRM/Editor/VrmTopMenu.cs b/Assets/VRM/Editor/VrmTopMenu.cs index 7c8caa901..d9aab4784 100644 --- a/Assets/VRM/Editor/VrmTopMenu.cs +++ b/Assets/VRM/Editor/VrmTopMenu.cs @@ -53,13 +53,13 @@ namespace VRM private static void ShowVersionDialog() => VRMVersionMenu.ShowVersionDialog(); [MenuItem(DevelopmentMenuPrefix + "/Build dummy for CI", false, 93)] - private static void BuildDummyForCi() => BuildClass.Build(); + private static void BuildDummyForCi() => DevOnly.BuildClass.Build(); - [MenuItem(DevelopmentMenuPrefix + "/Build 0x WebGL for CI", false, 94)] - private static void BuildWebGLForCi0x() => BuildClass.BuildWebGL_SimpleViewer(); + [MenuItem(DevelopmentMenuPrefix + "/Switch to built-in RenderPipeline", false, 94)] + private static void SwitchToBuiltinPipeline() => DevOnly.BuildClass.SwitchBuiltinPipeline(); - [MenuItem(DevelopmentMenuPrefix + "/Build 10 WebGL for CI", false, 95)] - private static void BuildWebGLForCi10() => BuildClass.BuildWebGL_VRM10Viewer(); + [MenuItem(DevelopmentMenuPrefix + "/Build WebGL SimpleViewer for CI", false, 95)] + private static void BuildWebGLForCi0x() => DevOnly.BuildClass.BuildWebGL_SimpleViewer(); [MenuItem(DevelopmentMenuPrefix + "/Create UnityPackage", false, 99)] private static void CreateUnityPackage() => VRMExportUnityPackage.CreateUnityPackageWithoutBuild(); diff --git a/Assets/VRM10/Editor/BuildClass.cs b/Assets/VRM10/Editor/BuildClass.cs new file mode 100644 index 000000000..230151a98 --- /dev/null +++ b/Assets/VRM10/Editor/BuildClass.cs @@ -0,0 +1,27 @@ +using UnityEditor; + +namespace UniVRM10.DevOnly +{ + public static class BuildClass + { + public static void BuildWebGL_VRM10Viewer() + { + var scenes = new string[]{ + "./Assets/VRM10_Samples/VRM10Viewer/VRM10Viewer.unity", + }; + + var report = BuildPipeline.BuildPlayer(new BuildPlayerOptions + { + scenes = scenes, + locationPathName = "Build/VRM10Viewer", + target = BuildTarget.WebGL, + } + ); + + if (report.summary.result != UnityEditor.Build.Reporting.BuildResult.Succeeded) + { + throw new System.Exception(report.summary.ToString()); + } + } + } +} \ No newline at end of file diff --git a/Assets/VRM10/Editor/BuildClass.cs.meta b/Assets/VRM10/Editor/BuildClass.cs.meta new file mode 100644 index 000000000..df70f0176 --- /dev/null +++ b/Assets/VRM10/Editor/BuildClass.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3783cb4bfaca889418092d0fdde301ad +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM10/Editor/Vrm10TopMenu.cs b/Assets/VRM10/Editor/Vrm10TopMenu.cs index e0cc2d8eb..ace2ff2cf 100644 --- a/Assets/VRM10/Editor/Vrm10TopMenu.cs +++ b/Assets/VRM10/Editor/Vrm10TopMenu.cs @@ -26,6 +26,9 @@ namespace UniVRM10 [MenuItem(DevelopmentMenuPrefix + "/Generate from JsonSchema(debug)", false, 101)] private static void Parse() => Vrm10SerializerGenerator.Run(true); + + [MenuItem(DevelopmentMenuPrefix + "/Build WebGL VRM10Viewer for CI", false, 201)] + private static void BuildWebGLForCi10() => DevOnly.BuildClass.BuildWebGL_VRM10Viewer(); #endif } }