Class MetadataListAdaptor
Inherited Members
Namespace: Unity.VisualScripting
Assembly: Unity.VisualScripting.Core.Editor.dll
Syntax
public class MetadataListAdaptor : MetadataCollectionAdaptor, IReorderableListAdaptor, IReorderableListDropTarget
Constructors
MetadataListAdaptor(Metadata, Inspector)
Declaration
public MetadataListAdaptor(Metadata metadata, Inspector parentInspector)
Parameters
Type | Name | Description |
---|---|---|
Metadata | metadata | |
Inspector | parentInspector |
Properties
Count
Gets count of elements in list.
Declaration
public override int Count { get; }
Property Value
Type | Description |
---|---|
int |
Overrides
this[int]
Declaration
public object this[int index] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
int | index |
Property Value
Type | Description |
---|---|
object |
alwaysDragAndDrop
Declaration
public bool alwaysDragAndDrop { get; set; }
Property Value
Type | Description |
---|---|
bool |
metadata
Declaration
public Metadata metadata { get; }
Property Value
Type | Description |
---|---|
Metadata |
Methods
Add()
Add new element at end of list.
Declaration
public override void Add()
Overrides
CanAdd()
Declaration
protected virtual bool CanAdd()
Returns
Type | Description |
---|---|
bool |
CanDrag(int)
Determines whether an item can be reordered by dragging mouse.
Declaration
public override bool CanDrag(int index)
Parameters
Type | Name | Description |
---|---|---|
int | index | Zero-based index for list element. |
Returns
Type | Description |
---|---|
bool | A value of |
Overrides
Remarks
This should be a light-weight method since it will be used to determine whether grab handle should be included for each item in a reorderable list.
Please note that returning a value of false
does not prevent movement
on list item since other draggable items can be moved around it.
CanDrop(object)
Declaration
protected virtual bool CanDrop(object item)
Parameters
Type | Name | Description |
---|---|---|
object | item |
Returns
Type | Description |
---|---|
bool |
CanDropInsert(int)
Determines whether an item is being dragged and that it can be inserted or moved by dropping somewhere into the reorderable list control.
Declaration
public bool CanDropInsert(int insertionIndex)
Parameters
Type | Name | Description |
---|---|---|
int | insertionIndex | Zero-based index of insertion. |
Returns
Type | Description |
---|---|
bool | A value of |
Remarks
This method is always called whilst drawing an editor GUI.
See Also
CanRemove(int)
Determines whether an item can be removed from list.
Declaration
public override bool CanRemove(int index)
Parameters
Type | Name | Description |
---|---|---|
int | index | Zero-based index for list element. |
Returns
Type | Description |
---|---|
bool | A value of |
Overrides
Remarks
This should be a light-weight method since it will be used to determine whether remove button should be included for each item in list.
This is redundant when HideRemoveButtons is specified.
Clear()
Clear all elements from list.
Declaration
public override void Clear()
Overrides
ConstructItem()
Declaration
protected virtual object ConstructItem()
Returns
Type | Description |
---|---|
object |
ConstructList()
Declaration
protected virtual IList ConstructList()
Returns
Type | Description |
---|---|
IList |
DrawItem(Rect, int)
Draws main interface for a list item.
Declaration
public override void DrawItem(Rect position, int index)
Parameters
Type | Name | Description |
---|---|---|
Rect | position | Position in GUI. |
int | index | Zero-based index of array element. |
Overrides
Remarks
This method is used to handle all GUI events.
DrawItemBackground(Rect, int)
Draws background of a list item.
Declaration
public override void DrawItemBackground(Rect position, int index)
Parameters
Type | Name | Description |
---|---|---|
Rect | position | Total position of list element in GUI. |
int | index | Zero-based index of array element. |
Overrides
Remarks
This method is only used to handle GUI repaint events.
Background of list item spans a slightly larger area than the main interface that is drawn by DrawItem(Rect, int) since it is drawn behind the grab handle.
Duplicate(int)
Duplicate existing element.
Declaration
public override void Duplicate(int index)
Parameters
Type | Name | Description |
---|---|---|
int | index | Zero-based index of list element. |
Overrides
Remarks
Consider using the ICloneable interface to duplicate list elements where appropriate.
GetItemAdaptiveWidth(int)
Declaration
public override float GetItemAdaptiveWidth(int index)
Parameters
Type | Name | Description |
---|---|---|
int | index |
Returns
Type | Description |
---|---|
float |
Overrides
GetItemHeight(float, int)
Declaration
public override float GetItemHeight(float width, int index)
Parameters
Type | Name | Description |
---|---|---|
float | width | |
int | index |
Returns
Type | Description |
---|---|
float |
Overrides
Insert(int)
Insert new element at specified index.
Declaration
public override void Insert(int index)
Parameters
Type | Name | Description |
---|---|---|
int | index | Zero-based index for list element. |
Overrides
Move(int, int)
Move element from source index to destination index.
Declaration
public override void Move(int sourceIndex, int destinationIndex)
Parameters
Type | Name | Description |
---|---|---|
int | sourceIndex | Zero-based index of source element. |
int | destinationIndex |
Overrides
ProcessDropInsertion(int)
Processes the current drop insertion operation when CanDropInsert(int)
returns a value of true
to process, accept or cancel.
Declaration
public void ProcessDropInsertion(int insertionIndex)
Parameters
Type | Name | Description |
---|---|---|
int | insertionIndex | Zero-based index of insertion. |
Remarks
This method is always called whilst drawing an editor GUI.
This method is only called when CanDropInsert(int)
returns a value of true
.
See Also
Remove(int)
Remove element at specified index.
Declaration
public override void Remove(int index)
Parameters
Type | Name | Description |
---|---|---|
int | index | Zero-based index of list element. |
Overrides
Events
itemAdded
Declaration
public event Action<object> itemAdded
Event Type
Type | Description |
---|---|
Action<object> |