Skip to content

Commit 4c4041a

Browse files
authored
Merge pull request #231 from jwittner/dev/supportUnity2021
Fix for detecting unity 2021 version and windows il2cpp
2 parents 7a444d4 + 3c7f752 commit 4c4041a

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

UnitySetup/UnitySetup.psm1

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ class UnitySetupInstance {
6565
@{
6666
[UnitySetupComponent]::Documentation = , [io.path]::Combine("$Path", "Editor\Data\Documentation");
6767
[UnitySetupComponent]::StandardAssets = , [io.path]::Combine("$Path", "Editor\Standard Assets");
68-
[UnitySetupComponent]::Windows_IL2CPP = , [io.path]::Combine("$playbackEnginePath", "windowsstandalonesupport\Variations\win32_development_il2cpp");
68+
[UnitySetupComponent]::Windows_IL2CPP = , [io.path]::Combine("$playbackEnginePath", "windowsstandalonesupport\Variations\win32_development_il2cpp"),
69+
[io.path]::Combine("$playbackEnginePath", "windowsstandalonesupport\Variations\win32_player_development_il2cpp");;
6970
[UnitySetupComponent]::UWP = [io.path]::Combine("$playbackEnginePath", "MetroSupport\Templates\UWP_.NET_D3D"),
7071
[io.path]::Combine("$playbackEnginePath", "MetroSupport\Templates\UWP_D3D");
7172
[UnitySetupComponent]::UWP_IL2CPP = , [io.path]::Combine("$playbackEnginePath", "MetroSupport\Templates\UWP_IL2CPP_D3D");
@@ -1278,28 +1279,33 @@ function Get-UnitySetupInstanceVersion {
12781279
}
12791280

12801281
# Search through any header files which might define the unity version
1281-
[string[]]$knownHeaders = @(
1282-
"$path\Editor\Data\PlaybackEngines\windowsstandalonesupport\Source\WindowsPlayer\WindowsPlayer\UnityConfigureVersion.gen.h"
1282+
[string[]]$knownFiles = @(
1283+
"$path\Editor\Data\PlaybackEngines\windowsstandalonesupport\Source\WindowsPlayer\WindowsPlayer\UnityConfigureVersion.gen.h",
1284+
"$path\Editor\Data\PlaybackEngines\windowsstandalonesupport\Source\WindowsPlayer\WindowsPlayer\UnityConfiguration.gen.cpp"
12831285
)
1284-
foreach ($header in $knownHeaders) {
1285-
Write-Verbose "Looking for UNITY_VERSION defined in $header"
1286-
if (Test-Path -PathType Leaf -Path $header) {
1287-
$headerMatchInfo = Select-String -Path $header -Pattern "UNITY_VERSION\s`"(\d+\.\d+\.\d+[fpba]\d+)`""
1286+
foreach ($file in $knownFiles) {
1287+
Write-Verbose "Looking for UNITY_VERSION defined in $file"
1288+
if (Test-Path -PathType Leaf -Path $file) {
1289+
$fileMatchInfo = Select-String -Path $file -Pattern "UNITY_VERSION.+`"(\d+\.\d+\.\d+[fpba]\d+).*`""
1290+
if($null -ne $fileMatchInfo)
1291+
{
1292+
break;
1293+
}
12881294
}
12891295
}
12901296

1291-
if ($null -eq $headerMatchInfo) {
1292-
Write-Verbose "Looking for .h files with UNITY_VERSION defined under $path\Editor\ "
1293-
$headerMatchInfo = do {
1294-
Get-ChildItem -Path "$path\Editor\*.h" -Recurse -ErrorAction Ignore -Force -File |
1295-
Select-String -Pattern "UNITY_VERSION\s`"(\d+\.\d+\.\d+[fpba]\d+)`"" |
1297+
if ($null -eq $fileMatchInfo) {
1298+
Write-Verbose "Looking for source files with UNITY_VERSION defined under $path\Editor\ "
1299+
$fileMatchInfo = do {
1300+
Get-ChildItem -Path "$path\Editor" -Include '*.cpp','*.h' -Recurse -ErrorAction Ignore -Force -File |
1301+
Select-String -Pattern "UNITY_VERSION.+`"(\d+\.\d+\.\d+[fpba]\d+).*`"" |
12961302
ForEach-Object { $_; break; } # Stop the pipeline after the first result
12971303
} while ($false);
12981304
}
12991305

1300-
if ( $headerMatchInfo.Matches.Groups.Count -gt 1 ) {
1306+
if ( $fileMatchInfo.Matches.Groups.Count -gt 1 ) {
13011307
Write-Verbose "`tFound version!"
1302-
return [UnityVersion]($headerMatchInfo.Matches.Groups[1].Value)
1308+
return [UnityVersion]($fileMatchInfo.Matches.Groups[1].Value)
13031309
}
13041310
}
13051311
}

0 commit comments

Comments
 (0)