Skip to content

Commit 263e1df

Browse files
committed
Improve types sorting capabilities
1 parent e0da418 commit 263e1df

3 files changed

Lines changed: 6 additions & 4 deletions

File tree

Assets/Editor Toolbox/Editor/Internal/TypeConstraintContext.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public override int GetHashCode()
4747

4848

4949
public Type TargetType => targetType;
50+
public Comparison<Type> Comparer { get; set; } = (t1, t2) => t1.Name.CompareTo(t2.Name);
5051
public bool IsOrdered { get; set; } = true;
5152
}
5253
}

Assets/Editor Toolbox/Editor/Utilities/TypeUtilities.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,11 @@ public static List<Type> FindTypes(TypeConstraintContext constraint)
103103
{
104104
typesList.AddRange(FindTypes(constraint, assembly));
105105
}
106-
107-
typesList.Sort((a, b) => a.FullName.CompareTo(b.FullName));
108106
#endif
109107
if (constraint.IsOrdered)
110108
{
111-
typesList.Sort((t1, t2) => t1.Name.CompareTo(t2.Name));
109+
var comparer = constraint.Comparer;
110+
typesList.Sort(comparer);
112111
}
113112

114113
return typesList;

Assets/Editor Toolbox/Editor/Wizards/ScriptableObjectCreationWizard.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ public class ScriptableObjectCreationWizard : ToolboxWizard
1919
private class TypeConstraintScriptableObject : TypeConstraintStandard
2020
{
2121
public TypeConstraintScriptableObject() : base(typeof(ScriptableObject), TypeSettings.Class, false, false)
22-
{ }
22+
{
23+
Comparer = (t1, t2) => t1.FullName.CompareTo(t2.FullName);
24+
}
2325

2426
public override bool IsSatisfied(Type type)
2527
{

0 commit comments

Comments
 (0)