Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config flag that drops -quit from builder #13

Open
dginovker opened this issue Feb 16, 2022 · 5 comments
Open

Add config flag that drops -quit from builder #13

dginovker opened this issue Feb 16, 2022 · 5 comments
Labels
enhancement New feature or request

Comments

@dginovker
Copy link

Context

My team has a situation where we can’t run playtests because of asmdef’s in Unity not working with our project flow, but instead found a way to validate things in-game by running a scene from the command line (scene is started from a static method). We want to start the scene to run the tests before a build, but you can't enter playmode from a static method in -batchmode if -quit is also present.

A configuration option that allows removing -quit from the Unity command line parameters would solve our issue (although it means we need to handle the exiting of the editor ourselves with EditorApplication.Exit(0))

Suggested solution

Add a config like

quit

Bool whether the editor should quit after building
Note: If quit is disabled, your build method must handle exiting Unity with EditorApplication.Exit(0) on its own
required: false default: true

Considered alternatives

Forking the builder and monkey patching it

Additional details

We can't call /opt/unity/Editor/Unity ourselves since it's gone when you leave the build step. It would also mean we have to redo the licensing/etc

The following is some bash code that can handle the optionally passing -quit, although I don't have an equivalent for the Powershell build.ps1

#!/usr/bin/env bash

function printparams() {
  echo "$@"
  echo "$#"
}

quit=""

printparams \
  ${quit} \
  -two

quit="-quit"

printparams \
  ${quit} \
  -two
@dginovker dginovker added the enhancement New feature or request label Feb 16, 2022
@webbertakken
Copy link
Member

webbertakken commented Feb 16, 2022

Yup sounds good!

Thank you for your nice suggestion and the details.
We should probably add a parameter called manualExit to our public api, which would be set to false by default.

Accepting PRs for this.

@webbertakken
Copy link
Member

Added this to the Roadmap to v3.0.0.

It should probably be configurable through a plugin.

@webbertakken webbertakken transferred this issue from game-ci/unity-builder Sep 1, 2022
@webbertakken
Copy link
Member

More use-case details in linked issue ^

@JohannesDeml
Copy link

For anyone else running into the limitation: As a quickfix you could just fork the repo and remove the -quit parameter for now. Example: https://github.com/JohannesDeml/unity-builder/commits/no-quit-parameter
Usage: https://github.com/JohannesDeml/UnityWebGL-LoadingTest/blob/master/.github/workflows/upgrade-unity.yml#L95

      - name: Build project
        uses: JohannesDeml/unity-builder@no-quit-parameter
        env:
          UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
        with:
          buildMethod: UnityBuilderAction.UnityPackageScripts.UpgradeAllPackagesToVerifiedVersion
          customParameters: ${{ inputs.customParameters }}
          unityVersion: ${{ inputs.unityVersion }}
          targetPlatform: WebGL
          buildName: ${{ needs.variables.outputs.BUILD_NAME }}
          allowDirtyBuild: true

@tobyspark
Copy link

I didn’t see any way to suppress -quit in the current v3 code, so made a PR. I called the option manualExit as suggested in this thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Todo
Development

No branches or pull requests

4 participants