Skip to content

Commit 690d3fe

Browse files
committed
Rename TypeConstraintReference to TypeConstraintSerializeReference
1 parent 637292e commit 690d3fe

6 files changed

Lines changed: 13 additions & 13 deletions

File tree

Assets/Editor Toolbox/Editor/Drawers/Toolbox/PropertySelf/ReferencePickerAttributeDrawer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class ReferencePickerAttributeDrawer : ToolboxSelfPropertyDrawer<Referenc
1212
{
1313
private const float labelWidthOffset = -80.0f;
1414

15-
private static readonly TypeConstraintContext sharedConstraint = new TypeConstraintReference(null);
15+
private static readonly TypeConstraintContext sharedConstraint = new TypeConstraintSerializeReference(null);
1616
private static readonly TypeAppearanceContext sharedAppearance = new TypeAppearanceContext(sharedConstraint, TypeGrouping.None, true);
1717
private static readonly TypeField typeField = new TypeField(sharedConstraint, sharedAppearance);
1818

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@ public class TypeConstraintContext
77
{
88
protected Type targetType;
99

10-
1110
public TypeConstraintContext(Type targetType)
1211
{
1312
this.targetType = targetType;
1413
}
1514

16-
1715
public virtual bool IsSatisfied(Type type)
1816
{
1917
#if UNITY_2019_2_OR_NEWER
@@ -45,7 +43,6 @@ public override int GetHashCode()
4543
return hashCode;
4644
}
4745

48-
4946
public Type TargetType => targetType;
5047
public Comparison<Type> Comparer { get; set; } = (t1, t2) => t1.Name.CompareTo(t2.Name);
5148
public bool IsOrdered { get; set; } = true;

Assets/Editor Toolbox/Editor/Internal/TypeConstraintReference.cs renamed to Assets/Editor Toolbox/Editor/Internal/TypeConstraintSerializeReference.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55

66
namespace Toolbox.Editor.Internal
77
{
8-
public class TypeConstraintReference : TypeConstraintContext
8+
/// <summary>
9+
/// Dedicated <see cref="TypeConstraintContext"/> for SerializeReference-based types.
10+
/// </summary>
11+
public class TypeConstraintSerializeReference : TypeConstraintContext
912
{
10-
public TypeConstraintReference(Type targetType) : base(targetType)
13+
public TypeConstraintSerializeReference(Type targetType) : base(targetType)
1114
{ }
1215

13-
1416
public override bool IsSatisfied(Type type)
1517
{
1618
return base.IsSatisfied(type) &&
@@ -25,7 +27,7 @@ public override bool IsSatisfied(Type type)
2527

2628
public override bool Equals(object other)
2729
{
28-
return other is TypeConstraintReference constraint &&
30+
return other is TypeConstraintSerializeReference constraint &&
2931
base.Equals(other) &&
3032
EqualityComparer<Type>.Default.Equals(targetType, constraint.targetType);
3133
}

Assets/Editor Toolbox/Editor/Internal/TypeConstraintReference.cs.meta renamed to Assets/Editor Toolbox/Editor/Internal/TypeConstraintSerializeReference.cs.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Editor Toolbox/Editor/Internal/TypeField.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,12 @@ private Type RetriveSelectedType(IReadOnlyList<Type> types, int selectedIndex, b
3737

3838
private void DrawTypeConflictWarning(Rect position)
3939
{
40-
const float warningSpace = 18.0f;
40+
const float warningSpace = 20.0f;
4141

4242
var warningPosition = position;
4343
warningPosition.xMax = position.xMin;
4444
warningPosition.xMin -= warningSpace;
45+
warningPosition.y += EditorGUIUtility.standardVerticalSpacing;
4546
var warningIcon = EditorGuiUtility.GetHelpIcon(MessageType.Warning);
4647
var warningLabel = new GUIContent(warningIcon, "Currently active type is not available from the selection. " +
4748
"It may be caused by a conflict between the type filter and cached data.");

Assets/Editor Toolbox/Tests/Editor/TypesFilteringTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,15 @@ public void TestStandardConstraintPass7()
139139
[Test]
140140
public void TestReferenceConstraintPass1()
141141
{
142-
var constraint = new TypeConstraintReference(typeof(Component));
142+
var constraint = new TypeConstraintSerializeReference(typeof(Component));
143143
var collection = TypeUtilities.GetCollection(constraint);
144144
Assert.AreEqual(0, collection.Values.Count);
145145
}
146146

147147
[Test]
148148
public void TestReferenceConstraintPass2()
149149
{
150-
var constraint = new TypeConstraintReference(typeof(ClassBase));
150+
var constraint = new TypeConstraintSerializeReference(typeof(ClassBase));
151151
var collection = TypeUtilities.GetCollection(constraint);
152152
Assert.IsTrue(collection.Contains(typeof(ClassWithInterface1)));
153153
#pragma warning disable CS0612
@@ -161,7 +161,7 @@ public void TestReferenceConstraintPass2()
161161
[Test]
162162
public void TestReferenceConstraintPass3()
163163
{
164-
var constraint = new TypeConstraintReference(typeof(Interface1));
164+
var constraint = new TypeConstraintSerializeReference(typeof(Interface1));
165165
var collection = TypeUtilities.GetCollection(constraint);
166166
Assert.IsTrue(collection.Contains(typeof(ClassWithInterface1)));
167167
#pragma warning disable CS0612

0 commit comments

Comments
 (0)