Skip to content

Commit f1ed815

Browse files
committed
fix icomparer sorting exception (with show missing projects enabled)
1 parent 9f335c0 commit f1ed815

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

UnityLauncherPro/GetProjects.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public static List<Project> Scan(bool getGitBranch = false, bool getPlasticBranc
6464
{
6565
projectsFound.Add(p);
6666

67-
// test adding to history
67+
// add found projects to history also (gets added only if its not already there)
6868
Tools.AddProjectToHistory(p.Path);
6969
}
7070
} // valid key
@@ -77,10 +77,10 @@ public static List<Project> Scan(bool getGitBranch = false, bool getPlasticBranc
7777
// scan info for custom folders (if not already on the list)
7878
if (AllProjectPaths != null)
7979
{
80-
// iterate custom full project history
80+
// iterate custom full projects history
8181
foreach (var projectPath in AllProjectPaths)
8282
{
83-
// check if registry list contains this path
83+
// check if registry list contains this path already, then skip it
8484
bool found = false;
8585
for (int i = 0, len = projectsFound.Count; i < len; i++)
8686
{
@@ -91,7 +91,7 @@ public static List<Project> Scan(bool getGitBranch = false, bool getPlasticBranc
9191
}
9292
}
9393

94-
// if not found from full history list, add to projects list
94+
// if not found from registry, add to recent projects list
9595
if (found == false)
9696
{
9797
var p = GetProjectInfo(projectPath, getGitBranch, getPlasticBranch, getArguments, showMissingFolders, showTargetPlatform);
@@ -100,20 +100,19 @@ public static List<Project> Scan(bool getGitBranch = false, bool getPlasticBranc
100100
}
101101
}
102102

103-
// NOTE sometimes projects are in wrong order, seems to be related to messing up your unity registry, the keys are received in created order (so if you had removed/modified them manually, it might return wrong order instead of 0 - 40)
103+
// sometimes projects are in wrong order, seems to be related to messing up your unity registry, the keys are received in created order (so if you had removed/modified them manually, it might return wrong order instead of 0 - 40)
104104
// thats why need to sort projects list by modified date
105105
// sort by modified date, projects without modified date are put to last, NOTE: this would remove projects without modified date (if they become last items, before trimming list on next step)
106106
projectsFound.Sort((x, y) =>
107107
{
108-
if (x.Modified == null && y.Modified == null) return -1; // was 0
108+
if (x.Modified == null && y.Modified == null) return 0; // cannot be -1, https://stackoverflow.com/a/42821992/5452781
109109
if (x.Modified == null) return 1;
110110
if (y.Modified == null) return -1;
111111
return y.Modified.Value.CompareTo(x.Modified.Value);
112112
//return x.Modified.Value.CompareTo(y.Modified.Value); // BUG this breaks something, so that last item platform is wrong (for project that is missing from disk) ?
113113
});
114-
//projectsFound.Sort((x, y) => y.Modified.Value.CompareTo(x.Modified.Value));
115114

116-
// trim list to max amount TODO only if enabled in settings
115+
// trim list to max amount
117116
if (projectsFound.Count > MainWindow.maxProjectCount)
118117
{
119118
//Console.WriteLine("Trimming projects list to " + MainWindow.maxProjectCount + " projects");
@@ -129,7 +128,6 @@ static Project GetProjectInfo(string projectPath, bool getGitBranch = false, boo
129128

130129
// if displaying missing folders are disabled, and folder doesnt exists, skip this project
131130
if (showMissingFolders == false && folderExists == false) return null;
132-
133131
string projectName = "";
134132

135133
// get project name from full path
@@ -179,7 +177,6 @@ static Project GetProjectInfo(string projectPath, bool getGitBranch = false, boo
179177
targetPlatform = folderExists ? Tools.GetTargetPlatform(projectPath) : null;
180178
//if (projectPath.Contains("Shader")) Console.WriteLine(projectPath + " targetPlatform=" + targetPlatform);
181179
}
182-
183180
var p = new Project();
184181

185182
switch (MainWindow.projectNameSetting)

0 commit comments

Comments
 (0)