Skip to content

Commit

Permalink
Possibility to change pickup dropdown type for the ReferencePickerAtt…
Browse files Browse the repository at this point in the history
…ributeDrawer
  • Loading branch information
arimger committed Jan 29, 2024
1 parent 8c73437 commit 1f6d113
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private Type GetParentType(ReferencePickerAttribute attribute, SerializedPropert
private void CreateTypeProperty(SerializedProperty property, Type parentType, ReferencePickerAttribute attribute, Rect position)
{
TypeUtilities.TryGetTypeFromManagedReferenceFullTypeName(property.managedReferenceFullTypename, out var currentType);
typeField.OnGui(position, true, (type) =>
typeField.OnGui(position, attribute.AddTextSearchField, (type) =>
{
try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,22 @@ public ReferencePickerAttribute(Type parentType, TypeGrouping typeGrouping)
}

public Type ParentType { get; set; }

/// <summary>
/// Indicates if created instance should be uninitialized.
/// </summary>
public bool ForceUninitializedInstance { get; set; }

/// <summary>
/// Gets or sets grouping of selectable classes.
/// Defaults to <see cref="TypeGrouping.None"/> unless explicitly specified.
/// </summary>
public TypeGrouping TypeGrouping { get; set; } = TypeGrouping.None;

public bool ForceUninitializedInstance { get; set; }
/// <summary>
/// Indicates if created popup menu should have an additional search field.
/// </summary>
public bool AddTextSearchField { get; set; } = true;
}
}
#endif
4 changes: 2 additions & 2 deletions Assets/Examples/Scripts/SampleBehaviour6.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ public class SampleBehaviour6 : MonoBehaviour
public Interface1 var1;
[SerializeReference, ReferencePicker(ForceUninitializedInstance = true)]
public ClassWithInterfaceBase var2;
[SerializeReference, ReferencePicker(ParentType = typeof(ClassWithInterface2))]
[SerializeReference, ReferencePicker(ParentType = typeof(ClassWithInterface2), AddTextSearchField = false)]
public ClassWithInterfaceBase var3;
[SerializeReference, ReferencePicker]
[SerializeReference, ReferencePicker, ReorderableList]
public Interface1[] vars;
#endif

Expand Down

0 comments on commit 1f6d113

Please sign in to comment.