Skip to content
This repository was archived by the owner on May 19, 2021. It is now read-only.

Commit 3b36a39

Browse files
committed
fix project upgrader
1 parent 248ec5e commit 3b36a39

File tree

3 files changed

+41
-12
lines changed

3 files changed

+41
-12
lines changed

UnityLauncher/Form1.cs

+20-11
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,11 @@ void Start()
6464
{
6565
SetStatus("Launching from commandline..");
6666

67-
var pathArg = args[2];
68-
LaunchProject(pathArg, true);
67+
var projectPathArgument = args[2];
68+
69+
var version = GetProjectVersion(projectPathArgument);
70+
71+
LaunchProject(projectPathArgument, version, true);
6972
SetStatus("Ready");
7073

7174
// quit after launch if enabled in settings
@@ -287,13 +290,13 @@ void UpdateRecentProjectsList()
287290
}
288291
}
289292

290-
void LaunchProject(string pathArg = null, bool openProject = true)
293+
void LaunchProject(string projectPath, string version, bool openProject = true)
291294
{
292-
if (Directory.Exists(pathArg) == true)
295+
if (Directory.Exists(projectPath) == true)
293296
{
294-
if (Directory.Exists(Path.Combine(pathArg, "Assets")))
297+
if (Directory.Exists(Path.Combine(projectPath, "Assets")))
295298
{
296-
var version = GetProjectVersion(pathArg);
299+
//var version = GetProjectVersion(projectPath);
297300
//Console.WriteLine("Detected project version: " + version);
298301

299302
bool haveExactVersion = HaveExactVersionInstalled(version);
@@ -309,7 +312,7 @@ void LaunchProject(string pathArg = null, bool openProject = true)
309312
myProcess.StartInfo.FileName = cmd;
310313
if (openProject == true)
311314
{
312-
var pars = " -projectPath " + "\"" + pathArg + "\"";
315+
var pars = " -projectPath " + "\"" + projectPath + "\"";
313316
myProcess.StartInfo.Arguments = pars;
314317
}
315318
myProcess.Start();
@@ -350,12 +353,12 @@ void LaunchProject(string pathArg = null, bool openProject = true)
350353
}
351354
else
352355
{
353-
SetStatus("No Assets folder founded in: " + pathArg);
356+
SetStatus("No Assets folder founded in: " + projectPath);
354357
}
355358
}
356359
else // given path doesnt exists, strange
357360
{
358-
SetStatus("Invalid Path:" + pathArg);
361+
SetStatus("Invalid Path: " + projectPath);
359362
}
360363
}
361364

@@ -498,7 +501,9 @@ void LaunchSelectedProject(bool openProject = true)
498501
if (selected > -1)
499502
{
500503
SetStatus("Launching project..");
501-
LaunchProject(gridRecent.Rows[selected].Cells["_path"].Value.ToString(), openProject);
504+
var projectPath = gridRecent.Rows[selected].Cells["_path"].Value.ToString();
505+
var version = GetProjectVersion(projectPath);
506+
LaunchProject(projectPath, version, openProject);
502507
SetStatus("Ready");
503508
}
504509
}
@@ -862,7 +867,7 @@ private static string FindNearestVersionFromSimilarVersions(string version, IEnu
862867
if (!stripped.ContainsKey(comparableVersion))
863868
{
864869
stripped.Add(comparableVersion, version);
865-
Console.WriteLine(comparableVersion + " : " + version);
870+
//Console.WriteLine(comparableVersion + " : " + version);
866871
}
867872

868873
var comparables = stripped.Keys.OrderBy(x => x).ToList();
@@ -894,10 +899,14 @@ void UpgradeProject()
894899
if (upgradeDialog.ShowDialog(this) == DialogResult.OK)
895900
{
896901
// yes, upgrade
902+
SetStatus("Upgrading project to " + Form2.currentVersion);
903+
var projectPath = gridRecent.Rows[selected].Cells["_path"].Value.ToString();
904+
LaunchProject(projectPath, Form2.currentVersion);
897905
}
898906
else
899907
{
900908
// cancelled
909+
SetStatus("Cancelled project upgrade");
901910
}
902911
upgradeDialog.Close();
903912

UnityLauncher/Form2.Designer.cs

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnityLauncher/Form2.cs

+19-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ private void Form2_Load(object sender, EventArgs e)
3131
if (string.IsNullOrEmpty(currentVersion) == false)
3232
{
3333
string nearestVersion = Form1.FindNearestVersion(currentVersion, Form1.unityList.Keys.ToList());
34-
Console.WriteLine("nearest:" + nearestVersion);
34+
//Console.WriteLine("nearest:" + nearestVersion);
3535

3636
// preselect most likely version
3737
int likelyIndex = lstUnityVersions.FindString(currentVersion);
@@ -45,5 +45,23 @@ private void Form2_Load(object sender, EventArgs e)
4545

4646
}
4747
}
48+
49+
private void btnConfirmUpgrade_Click(object sender, EventArgs e)
50+
{
51+
if (lstUnityVersions.SelectedIndex>-1)
52+
{
53+
currentVersion = lstUnityVersions.Items[lstUnityVersions.SelectedIndex].ToString();
54+
DialogResult = DialogResult.OK;
55+
}
56+
else
57+
{
58+
// no version selected
59+
}
60+
}
61+
62+
private void btnCancelUpgrade_Click(object sender, EventArgs e)
63+
{
64+
DialogResult = DialogResult.Cancel;
65+
}
4866
}
4967
}

0 commit comments

Comments
 (0)