Skip to content

Commit ae6e330

Browse files
committed
check unity version on project launch and open with that version (if it had changed and user hasnt updated recent project list recently)
1 parent f0ea77f commit ae6e330

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

UnityLauncherPro/Tools.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,11 @@ public static void ExploreFolder(string path)
189189
// NOTE holding alt key (when using alt+o) brings up unity project selector
190190
public static Process LaunchProject(Project proj, DataGrid dataGridRef = null, bool useInitScript = false)
191191
{
192-
// validate
192+
Console.WriteLine("Launching project " + proj.Title + " at " + proj.Path);
193+
193194
if (proj == null) return null;
194195
if (Directory.Exists(proj.Path) == false) return null;
195196

196-
Console.WriteLine("Launching project " + proj.Title + " at " + proj.Path);
197-
198197
// check if this project path has unity already running? (from lock file or process)
199198
// NOTE this check only works if previous unity instance was started while we were running
200199
if (ProcessHandler.IsRunning(proj.Path))
@@ -223,17 +222,24 @@ public static Process LaunchProject(Project proj, DataGrid dataGridRef = null, b
223222
return null;
224223
}
225224

225+
// check if project version has changed? (list is not updated, for example pulled new version from git)
226+
var version = GetProjectVersion(proj.Path);
227+
228+
if (string.IsNullOrEmpty(version) == false && version != proj.Version)
229+
{
230+
Console.WriteLine("Project version has changed from " + proj.Version + " to " + version);
231+
proj.Version = version;
232+
}
233+
234+
// check if we have this unity version installed
226235
var unityExePath = GetUnityExePath(proj.Version);
227236
if (unityExePath == null)
228237
{
229238
DisplayUpgradeDialog(proj, null);
230239
return null;
231240
}
232241

233-
// SetStatus("Launching project in Unity " + version);
234-
235242
Process newProcess = new Process();
236-
237243
try
238244
{
239245
var cmd = "\"" + unityExePath + "\"";

0 commit comments

Comments
 (0)