2022-01-25 21:18:15 +00:00
# Activates Unity
2023-10-31 06:55:39 +00:00
Write-Output " "
Write-Output " ########################### "
Write-Output " # Activating # "
Write-Output " ########################### "
Write-Output " "
2023-12-10 09:33:05 +00:00
if ( ( $null -ne $ { env : UNITY_SERIAL } ) -and ( $null -ne $ { env : UNITY_EMAIL } ) -and ( $null -ne $ { env : UNITY_PASSWORD } ) )
{
#
# SERIAL LICENSE MODE
#
# This will activate unity, using the serial activation process.
#
Write-Output " Requesting activation "
2023-11-12 13:47:03 +00:00
2023-12-11 01:02:50 +00:00
$ACTIVATION_OUTPUT = Start-Process -FilePath " $Env:UNITY_PATH /Editor/Unity.exe " `
-NoNewWindow `
-PassThru `
-ArgumentList " -batchmode `
-quit `
-nographics `
-username $Env:UNITY_EMAIL `
-password $Env:UNITY_PASSWORD `
-serial $Env:UNITY_SERIAL `
-projectPath c: / BlankProject `
-logfile - "
# Cache the handle so exit code works properly
# https://stackoverflow.com/questions/10262231/obtaining-exitcode-using-start-process-and-waitforexit-instead-of-wait
$unityHandle = $ACTIVATION_OUTPUT . Handle
while ( $true ) {
if ( $ACTIVATION_OUTPUT . HasExited ) {
$ACTIVATION_EXIT_CODE = $ACTIVATION_OUTPUT . ExitCode
# Display results
if ( $ACTIVATION_EXIT_CODE -eq 0 )
{
Write-Output " Activation Succeeded "
} else
{
Write-Output " Activation failed, with exit code $ACTIVATION_EXIT_CODE "
}
break
}
Start-Sleep -Seconds 3
}
2023-12-10 09:33:05 +00:00
}
else
{
#
# NO LICENSE ACTIVATION STRATEGY MATCHED
#
# This will exit since no activation strategies could be matched.
#
Write-Output " License activation strategy could not be determined. "
Write-Output " "
Write-Output " Visit https://game.ci/docs/github/activation for more "
Write-Output " details on how to set up one of the possible activation strategies. "
Write-Output " ::error ::No valid license activation strategy could be determined. Make sure to provide UNITY_EMAIL, UNITY_PASSWORD, and either a UNITY_SERIAL \
or UNITY_LICENSE . Otherwise please use UNITY_LICENSING_SERVER . See more info at https : / / game . ci / docs / github / activation "
$ACTIVATION_EXIT_CODE = 1 ;
}