@@ -1177,6 +1177,7 @@ function Get-UnitySetupInstanceVersion {
1177
1177
1178
1178
Write-Verbose " Attempting to find UnityVersion in $path "
1179
1179
1180
+ # Try to look in the modules.json file for installer paths that contain version info
1180
1181
if ( Test-Path " $path \modules.json" - PathType Leaf ) {
1181
1182
1182
1183
Write-Verbose " Searching $path \modules.json for module versions"
@@ -1191,9 +1192,10 @@ function Get-UnitySetupInstanceVersion {
1191
1192
}
1192
1193
}
1193
1194
1195
+ # No version found, start digging deeper
1194
1196
if ( Test-Path " $path \Editor" - PathType Container ) {
1195
- # We'll attempt to search for the version using the ivy.xml definitions for legacy editor compatibility.
1196
-
1197
+
1198
+ # Search for the version using the ivy.xml definitions for legacy editor compatibility.
1197
1199
Write-Verbose " Looking for ivy.xml files under $path \Editor\"
1198
1200
$ivyFiles = Get-ChildItem - Path " $path \Editor\" - Filter ' ivy.xml' - Recurse - ErrorAction SilentlyContinue - Force - File
1199
1201
foreach ( $ivy in $ivyFiles ) {
@@ -1203,11 +1205,22 @@ function Get-UnitySetupInstanceVersion {
1203
1205
1204
1206
[xml ]$xmlDoc = Get-Content $ivy.FullName
1205
1207
1206
- [string ]$version = $xmlDoc .' ivy-module' .info.unityVersion
1207
- if ( -not $version ) { continue ; }
1208
+ [string ]$ivyVersion = $xmlDoc .' ivy-module' .info.unityVersion
1209
+ if ( -not $ivyVersion ) { continue ; }
1210
+
1211
+ Write-Verbose " `t Found version!"
1212
+ return [UnityVersion ]$ivyVersion
1213
+ }
1214
+
1215
+ # Search through any header files which might define the unity version
1216
+ Write-Verbose " Looking for .h files with UNITY_VERSION defined under $path \Editor\ "
1217
+ $headerMatchInfo = Get-ChildItem - Path " $path \Editor\*.h" - Recurse - ErrorAction Ignore - Force - File |
1218
+ Select-String - Pattern " UNITY_VERSION\s`" (\d+\.\d+\.\d+[fpba]\d+)`" " |
1219
+ Select-Object - First 1
1208
1220
1221
+ if ( $headerMatchInfo.Matches.Groups.Count -gt 1 ) {
1209
1222
Write-Verbose " `t Found version!"
1210
- return [UnityVersion ]$version
1223
+ return [UnityVersion ]( $headerMatchInfo .Matches.Groups [ 1 ].Value)
1211
1224
}
1212
1225
}
1213
1226
}
0 commit comments