Add 'enableGpu' param, allowing running Unity w/o `-nographics` (#636)

pull/639/head
Szymon Sirocki 2024-03-07 16:50:30 +01:00 committed by GitHub
parent e820c9ce7b
commit fc0a52b805
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 41 additions and 2 deletions

View File

@ -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: ''

7
dist/index.js generated vendored
View File

@ -303,6 +303,7 @@ class BuildParameters {
buildMethod: input_1.default.buildMethod,
buildVersion,
manualExit: input_1.default.manualExit,
enableGpu: input_1.default.enableGpu,
androidVersionCode,
androidKeystoreName: input_1.default.androidKeystoreName,
androidKeystoreBase64: input_1.default.androidKeystoreBase64,
@ -6430,6 +6431,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 },
@ -6984,6 +6986,10 @@ class Input {
const input = Input.getInput('manualExit') ?? false;
return input === 'true';
}
static get enableGpu() {
const input = Input.getInput('enableGpu') ?? false;
return input === 'true';
}
static get customParameters() {
return Input.getInput('customParameters') ?? '';
}
@ -7455,6 +7461,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();
}
}
SetupMac.unityHubBasePath = `/Applications/"Unity Hub.app"`;

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -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" \

View File

@ -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;
@ -157,6 +158,7 @@ class BuildParameters {
buildMethod: Input.buildMethod,
buildVersion,
manualExit: Input.manualExit,
enableGpu: Input.enableGpu,
androidVersionCode,
androidKeystoreName: Input.androidKeystoreName,
androidKeystoreBase64: Input.androidKeystoreBase64,

View File

@ -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 },

View File

@ -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');

View File

@ -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') ?? '';
}

View File

@ -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();
}
}