Skip to content

Commit 2ea10b8

Browse files
authored
Merge pull request #212 from derekfreed/fix/GetUnityProjectInstance
UnityProjectInstance fixed for older Unity versions
2 parents 75fc290 + 75dcdf2 commit 2ea10b8

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

UnitySetup/UnitySetup.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
RootModule = 'UnitySetup'
1515

1616
# Version number of this module.
17-
ModuleVersion = '5.3'
17+
ModuleVersion = '5.4'
1818

1919
# Supported PSEditions
2020
# CompatiblePSEditions = @()

UnitySetup/UnitySetup.psm1

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,19 @@ class UnityProjectInstance {
125125
$projectSettingsFile = [io.path]::Combine($path, "ProjectSettings\ProjectSettings.asset")
126126
if (!(Test-Path $projectSettingsFile)) { throw "Project is missing ProjectSettings.asset" }
127127

128-
$prodName = ((Get-Content $projectSettingsFile -Raw | ConvertFrom-Yaml)['playerSettings'])['productName']
129-
if (!$prodName) { throw "ProjectSettings is missing productName" }
128+
try {
129+
$prodName = ((Get-Content $projectSettingsFile -Raw | ConvertFrom-Yaml)['playerSettings'])['productName']
130+
if (!$prodName) { throw "ProjectSettings is missing productName" }
131+
}
132+
catch {
133+
$msg = "Could not read $projectSettingsFile, in the Unity project try setting Editor Settings > Asset Serialiazation Mode to 'Force Text'."
134+
$msg += "`nAn Exception was caught!"
135+
$msg += "`nException Type: $($_.Exception.GetType().FullName)"
136+
$msg += "`nException Message: $($_.Exception.Message)"
137+
Write-Warning -Message $msg
138+
139+
$prodName = $null
140+
}
130141

131142
$this.Path = $path
132143
$this.Version = $fileVersion

0 commit comments

Comments
 (0)