Skip to content

Commit 1f6d113

Browse files
committed
Possibility to change pickup dropdown type for the ReferencePickerAttributeDrawer
1 parent 8c73437 commit 1f6d113

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ private Type GetParentType(ReferencePickerAttribute attribute, SerializedPropert
4343
private void CreateTypeProperty(SerializedProperty property, Type parentType, ReferencePickerAttribute attribute, Rect position)
4444
{
4545
TypeUtilities.TryGetTypeFromManagedReferenceFullTypeName(property.managedReferenceFullTypename, out var currentType);
46-
typeField.OnGui(position, true, (type) =>
46+
typeField.OnGui(position, attribute.AddTextSearchField, (type) =>
4747
{
4848
try
4949
{

Assets/Editor Toolbox/Runtime/Attributes/Toolbox/PropertySelfAttributes/ReferencePickerAttribute.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,22 @@ public ReferencePickerAttribute(Type parentType, TypeGrouping typeGrouping)
2626
}
2727

2828
public Type ParentType { get; set; }
29+
30+
/// <summary>
31+
/// Indicates if created instance should be uninitialized.
32+
/// </summary>
33+
public bool ForceUninitializedInstance { get; set; }
34+
2935
/// <summary>
3036
/// Gets or sets grouping of selectable classes.
3137
/// Defaults to <see cref="TypeGrouping.None"/> unless explicitly specified.
3238
/// </summary>
3339
public TypeGrouping TypeGrouping { get; set; } = TypeGrouping.None;
3440

35-
public bool ForceUninitializedInstance { get; set; }
41+
/// <summary>
42+
/// Indicates if created popup menu should have an additional search field.
43+
/// </summary>
44+
public bool AddTextSearchField { get; set; } = true;
3645
}
3746
}
3847
#endif

Assets/Examples/Scripts/SampleBehaviour6.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ public class SampleBehaviour6 : MonoBehaviour
1111
public Interface1 var1;
1212
[SerializeReference, ReferencePicker(ForceUninitializedInstance = true)]
1313
public ClassWithInterfaceBase var2;
14-
[SerializeReference, ReferencePicker(ParentType = typeof(ClassWithInterface2))]
14+
[SerializeReference, ReferencePicker(ParentType = typeof(ClassWithInterface2), AddTextSearchField = false)]
1515
public ClassWithInterfaceBase var3;
16-
[SerializeReference, ReferencePicker]
16+
[SerializeReference, ReferencePicker, ReorderableList]
1717
public Interface1[] vars;
1818
#endif
1919

0 commit comments

Comments
 (0)