Skip to content

Commit 3c7f752

Browse files
committed
Fix for detecting unity 2021 version and windows il2cpp
1 parent 6dd8910 commit 3c7f752

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
@@ -64,7 +64,8 @@ class UnitySetupInstance {
6464
@{
6565
[UnitySetupComponent]::Documentation = , [io.path]::Combine("$Path", "Editor\Data\Documentation");
6666
[UnitySetupComponent]::StandardAssets = , [io.path]::Combine("$Path", "Editor\Standard Assets");
67-
[UnitySetupComponent]::Windows_IL2CPP = , [io.path]::Combine("$playbackEnginePath", "windowsstandalonesupport\Variations\win32_development_il2cpp");
67+
[UnitySetupComponent]::Windows_IL2CPP = , [io.path]::Combine("$playbackEnginePath", "windowsstandalonesupport\Variations\win32_development_il2cpp"),
68+
[io.path]::Combine("$playbackEnginePath", "windowsstandalonesupport\Variations\win32_player_development_il2cpp");;
6869
[UnitySetupComponent]::UWP = [io.path]::Combine("$playbackEnginePath", "MetroSupport\Templates\UWP_.NET_D3D"),
6970
[io.path]::Combine("$playbackEnginePath", "MetroSupport\Templates\UWP_D3D");
7071
[UnitySetupComponent]::UWP_IL2CPP = , [io.path]::Combine("$playbackEnginePath", "MetroSupport\Templates\UWP_IL2CPP_D3D");
@@ -1274,28 +1275,33 @@ function Get-UnitySetupInstanceVersion {
12741275
}
12751276

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

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

1296-
if ( $headerMatchInfo.Matches.Groups.Count -gt 1 ) {
1302+
if ( $fileMatchInfo.Matches.Groups.Count -gt 1 ) {
12971303
Write-Verbose "`tFound version!"
1298-
return [UnityVersion]($headerMatchInfo.Matches.Groups[1].Value)
1304+
return [UnityVersion]($fileMatchInfo.Matches.Groups[1].Value)
12991305
}
13001306
}
13011307
}

0 commit comments

Comments
 (0)