Skip to content

Commit 2febb70

Browse files
author
Tim Gerken
committed
Expose productName in UnityProjectInstance
1 parent fa131b7 commit 2febb70

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ Find all the Unity projects recursively:
5555
Get-UnityProjectInstance -Recurse
5656
5757
# Example output:
58-
# Version Path
59-
# ------- ----
60-
# 2017.2.0f3 C:\Projects\Project1\OneUnity\
61-
# 2017.3.0f3 C:\Projects\Project1\TwoUnity\
62-
# 2017.1.1p1 C:\Projects\Project2\
63-
# 2017.1.2f1 C:\Projects\Project3\App.Unity\
58+
# Version Path ProductName
59+
# ------- ---- -----------
60+
# 2017.2.0f3 C:\Projects\Project1\OneUnity\ Contoso
61+
# 2017.3.0f3 C:\Projects\Project1\TwoUnity\ Northwind
62+
# 2017.1.1p1 C:\Projects\Project2\ My Cool App
63+
# 2017.1.2f1 C:\Projects\Project3\App.Unity\ TemplateProject
6464
```
6565
Launch the right Unity editor for a project:
6666
```powershell

UnitySetup/UnitySetup.psm1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ class UnitySetupInstance {
122122
class UnityProjectInstance {
123123
[UnityVersion]$Version
124124
[string]$Path
125+
[string]$ProductName
125126

126127
UnityProjectInstance([string]$path) {
127128
$versionFile = [io.path]::Combine($path, "ProjectSettings\ProjectVersion.txt")
@@ -130,8 +131,15 @@ class UnityProjectInstance {
130131
$fileVersion = (Get-Content $versionFile -Raw | ConvertFrom-Yaml)['m_EditorVersion'];
131132
if (!$fileVersion) { throw "Project is missing a version in: $versionFile"}
132133

134+
$projectSettingsFile = [io.path]::Combine($path, "ProjectSettings\ProjectSettings.asset")
135+
if (!(Test-Path $projectSettingsFile)) { throw "Project is missing ProjectSettings.asset"}
136+
137+
$prodName = ((Get-Content $projectSettingsFile -Raw | ConvertFrom-Yaml)['playerSettings'])['productName']
138+
if (!$prodName) { throw "ProjectSettings is missing productName"}
139+
133140
$this.Path = $path
134141
$this.Version = $fileVersion
142+
$this.ProductName = $prodName
135143
}
136144
}
137145

0 commit comments

Comments
 (0)