Skip to content

Commit

Permalink
Add 'enableGpu' param, allowing running Unity w/o -nographics (#636)
Browse files Browse the repository at this point in the history
  • Loading branch information
codenamesimon authored Mar 7, 2024
1 parent e820c9c commit fc0a52b
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 2 deletions.
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ inputs:
required: false
default: ''
description: 'Suppresses `-quit`. Exit your build method using `EditorApplication.Exit(0)` instead.'
enableGpu:
required: false
default: ''
description: 'Launches unity without specifying `-nographics`.'
customParameters:
required: false
default: ''
Expand Down
7 changes: 7 additions & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/platforms/mac/steps/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ echo ""
-logFile - \
$( [ "${MANUAL_EXIT}" == "true" ] || echo "-quit" ) \
-batchmode \
-nographics \
$( [ "${ENABLE_GPU}" == "true" ] || echo "-nographics" ) \
-username "$UNITY_EMAIL" \
-password "$UNITY_PASSWORD" \
-customBuildName "$BUILD_NAME" \
Expand Down
2 changes: 2 additions & 0 deletions src/model/build-parameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class BuildParameters {
public buildMethod!: string;
public buildVersion!: string;
public manualExit!: boolean;
public enableGpu!: boolean;
public androidVersionCode!: string;
public androidKeystoreName!: string;
public androidKeystoreBase64!: string;
Expand Down Expand Up @@ -157,6 +158,7 @@ class BuildParameters {
buildMethod: Input.buildMethod,
buildVersion,
manualExit: Input.manualExit,
enableGpu: Input.enableGpu,
androidVersionCode,
androidKeystoreName: Input.androidKeystoreName,
androidKeystoreBase64: Input.androidKeystoreBase64,
Expand Down
1 change: 1 addition & 0 deletions src/model/image-environment-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class ImageEnvironmentFactory {
{ name: 'BUILD_FILE', value: parameters.buildFile },
{ name: 'BUILD_METHOD', value: parameters.buildMethod },
{ name: 'MANUAL_EXIT', value: parameters.manualExit },
{ name: 'ENABLE_GPU', value: parameters.enableGpu },
{ name: 'VERSION', value: parameters.buildVersion },
{ name: 'ANDROID_VERSION_CODE', value: parameters.androidVersionCode },
{ name: 'ANDROID_KEYSTORE_NAME', value: parameters.androidKeystoreName },
Expand Down
18 changes: 18 additions & 0 deletions src/model/input.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,24 @@ describe('Input', () => {
});
});

describe('enableGpu', () => {
it('returns the default value', () => {
expect(Input.enableGpu).toStrictEqual(false);
});

it('returns true when string true is passed', () => {
const spy = jest.spyOn(core, 'getInput').mockReturnValue('true');
expect(Input.enableGpu).toStrictEqual(true);
expect(spy).toHaveBeenCalledTimes(1);
});

it('returns false when string false is passed', () => {
const spy = jest.spyOn(core, 'getInput').mockReturnValue('false');
expect(Input.enableGpu).toStrictEqual(false);
expect(spy).toHaveBeenCalledTimes(1);
});
});

describe('versioningStrategy', () => {
it('returns the default value', () => {
expect(Input.versioningStrategy).toStrictEqual('Semantic');
Expand Down
6 changes: 6 additions & 0 deletions src/model/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ class Input {
return input === 'true';
}

static get enableGpu(): boolean {
const input = Input.getInput('enableGpu') ?? false;

return input === 'true';
}

static get customParameters(): string {
return Input.getInput('customParameters') ?? '';
}
Expand Down
1 change: 1 addition & 0 deletions src/model/platform-setup/setup-mac.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ class SetupMac {
process.env.CUSTOM_PARAMETERS = buildParameters.customParameters;
process.env.CHOWN_FILES_TO = buildParameters.chownFilesTo;
process.env.MANUAL_EXIT = buildParameters.manualExit.toString();
process.env.ENABLE_GPU = buildParameters.enableGpu.toString();
}
}

Expand Down

0 comments on commit fc0a52b

Please sign in to comment.