Skip to content

Commit 1edea46

Browse files
Updated the UnitySetupInstance to search for the executable path and validate the version that way.
1 parent 13a3db3 commit 1edea46

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

UnitySetup/UnitySetup.psm1

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,23 @@ class UnitySetupInstance {
5151
UnitySetupInstance([string]$path) {
5252

5353
$currentOS = Get-OperatingSystem
54-
$ivyPath = switch ($currentOS) {
55-
([OperatingSystem]::Windows) { 'Editor\Data\UnityExtensions\Unity\Networking\ivy.xml' }
54+
$executable = switch ($currentOS) {
55+
([OperatingSystem]::Windows) { 'Editor\Unity.exe' }
5656
([OperatingSystem]::Linux) { throw "UnitySetupInstance has not been implemented on the Linux platform. Contributions welcomed!"; }
57-
([OperatingSystem]::Mac) { 'Unity.app/Contents/UnityExtensions/Unity/Networking/ivy.xml' }
57+
([OperatingSystem]::Mac) { 'Unity.app/Contents/MacOS/Unity/Unity.exe' } # TODO Validate path
5858
}
5959

60-
$ivyPath = [io.path]::Combine("$path", $ivyPath);
61-
if (!(Test-Path $ivyPath)) { throw "Path is not a Unity setup: $path"}
62-
[xml]$xmlDoc = Get-Content $ivyPath
60+
$executable = [io.path]::Combine("$path", $executable);
61+
if (!(Test-Path $executable)) { throw "Path is not a Unity setup: $path"}
6362

64-
if ( !($xmlDoc.'ivy-module'.info.unityVersion)) {
65-
throw "Unity setup ivy is missing version: $ivyPath"
63+
$version = switch($currentOS) {
64+
([OperatingSystem]::Windows) { Split-Path (Split-Path -Path $executable -Parent | Split-Path -Parent) -Leaf }
65+
([OperatingSystem]::Linux) { throw "UnitySetupInstance has not been implemented on the Linux platform. Contributions welcomed!"; }
66+
([OperatingSystem]::Mac) { ??? }
6667
}
6768

6869
$this.Path = $path
69-
$this.Version = $xmlDoc.'ivy-module'.info.unityVersion
70+
$this.Version = $version
7071

7172
$playbackEnginePath = $null
7273
$componentTests = switch ($currentOS) {
@@ -970,7 +971,7 @@ function Install-UnitySetupInstance {
970971

971972
$editorInstaller = $installerPaths | Where-Object { $_.ComponentType -band $editorComponent }
972973
if ($null -ne $editorInstaller) {
973-
Write-Verbose "Installing $($editorInstaller.ComponentType)"
974+
Write-Verbose "Installing $($editorInstaller.ComponentType) Editor"
974975
Install-UnitySetupPackage -Package $editorInstaller -Destination $packageDestination
975976
}
976977

0 commit comments

Comments
 (0)