Skip to content

Commit fc0a52b

Browse files
Add 'enableGpu' param, allowing running Unity w/o -nographics (#636)
1 parent e820c9c commit fc0a52b

File tree

9 files changed

+41
-2
lines changed

9 files changed

+41
-2
lines changed

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ inputs:
3535
required: false
3636
default: ''
3737
description: 'Suppresses `-quit`. Exit your build method using `EditorApplication.Exit(0)` instead.'
38+
enableGpu:
39+
required: false
40+
default: ''
41+
description: 'Launches unity without specifying `-nographics`.'
3842
customParameters:
3943
required: false
4044
default: ''

dist/index.js

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/platforms/mac/steps/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ echo ""
131131
-logFile - \
132132
$( [ "${MANUAL_EXIT}" == "true" ] || echo "-quit" ) \
133133
-batchmode \
134-
-nographics \
134+
$( [ "${ENABLE_GPU}" == "true" ] || echo "-nographics" ) \
135135
-username "$UNITY_EMAIL" \
136136
-password "$UNITY_PASSWORD" \
137137
-customBuildName "$BUILD_NAME" \

src/model/build-parameters.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class BuildParameters {
3232
public buildMethod!: string;
3333
public buildVersion!: string;
3434
public manualExit!: boolean;
35+
public enableGpu!: boolean;
3536
public androidVersionCode!: string;
3637
public androidKeystoreName!: string;
3738
public androidKeystoreBase64!: string;
@@ -157,6 +158,7 @@ class BuildParameters {
157158
buildMethod: Input.buildMethod,
158159
buildVersion,
159160
manualExit: Input.manualExit,
161+
enableGpu: Input.enableGpu,
160162
androidVersionCode,
161163
androidKeystoreName: Input.androidKeystoreName,
162164
androidKeystoreBase64: Input.androidKeystoreBase64,

src/model/image-environment-factory.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class ImageEnvironmentFactory {
4242
{ name: 'BUILD_FILE', value: parameters.buildFile },
4343
{ name: 'BUILD_METHOD', value: parameters.buildMethod },
4444
{ name: 'MANUAL_EXIT', value: parameters.manualExit },
45+
{ name: 'ENABLE_GPU', value: parameters.enableGpu },
4546
{ name: 'VERSION', value: parameters.buildVersion },
4647
{ name: 'ANDROID_VERSION_CODE', value: parameters.androidVersionCode },
4748
{ name: 'ANDROID_KEYSTORE_NAME', value: parameters.androidKeystoreName },

src/model/input.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,24 @@ describe('Input', () => {
122122
});
123123
});
124124

125+
describe('enableGpu', () => {
126+
it('returns the default value', () => {
127+
expect(Input.enableGpu).toStrictEqual(false);
128+
});
129+
130+
it('returns true when string true is passed', () => {
131+
const spy = jest.spyOn(core, 'getInput').mockReturnValue('true');
132+
expect(Input.enableGpu).toStrictEqual(true);
133+
expect(spy).toHaveBeenCalledTimes(1);
134+
});
135+
136+
it('returns false when string false is passed', () => {
137+
const spy = jest.spyOn(core, 'getInput').mockReturnValue('false');
138+
expect(Input.enableGpu).toStrictEqual(false);
139+
expect(spy).toHaveBeenCalledTimes(1);
140+
});
141+
});
142+
125143
describe('versioningStrategy', () => {
126144
it('returns the default value', () => {
127145
expect(Input.versioningStrategy).toStrictEqual('Semantic');

src/model/input.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,12 @@ class Input {
133133
return input === 'true';
134134
}
135135

136+
static get enableGpu(): boolean {
137+
const input = Input.getInput('enableGpu') ?? false;
138+
139+
return input === 'true';
140+
}
141+
136142
static get customParameters(): string {
137143
return Input.getInput('customParameters') ?? '';
138144
}

src/model/platform-setup/setup-mac.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ class SetupMac {
189189
process.env.CUSTOM_PARAMETERS = buildParameters.customParameters;
190190
process.env.CHOWN_FILES_TO = buildParameters.chownFilesTo;
191191
process.env.MANUAL_EXIT = buildParameters.manualExit.toString();
192+
process.env.ENABLE_GPU = buildParameters.enableGpu.toString();
192193
}
193194
}
194195

0 commit comments

Comments
 (0)