docs.unity3d.com
    Show / Hide Table of Contents

    Class GridView

    A view containing recycled rows with items inside.

    Inheritance
    Object
    CallbackEventHandler
    Focusable
    VisualElement
    BindableElement
    GridView
    Inherited Members
    BindableElement.binding
    BindableElement.bindingPath
    VisualElement.disabledUssClassName
    UnityEngine.UIElements.VisualElement.ExecuteDefaultAction(UnityEngine.UIElements.EventBase)
    UnityEngine.UIElements.VisualElement.Focus()
    VisualElement.SendEvent(EventBase)
    UnityEngine.UIElements.VisualElement.SetEnabledFromHierarchy(System.Boolean)
    VisualElement.SetEnabled(Boolean)
    VisualElement.MarkDirtyRepaint()
    VisualElement.ContainsPoint(Vector2)
    UnityEngine.UIElements.VisualElement.Overlaps(UnityEngine.Rect)
    UnityEngine.UIElements.VisualElement.DoMeasure(System.Single, UnityEngine.UIElements.VisualElement.MeasureMode, System.Single, UnityEngine.UIElements.VisualElement.MeasureMode)
    UnityEngine.UIElements.VisualElement.ToString()
    VisualElement.GetClasses()
    VisualElement.ClearClassList()
    VisualElement.AddToClassList(String)
    VisualElement.RemoveFromClassList(String)
    VisualElement.ToggleInClassList(String)
    VisualElement.EnableInClassList(String, Boolean)
    VisualElement.ClassListContains(String)
    VisualElement.FindAncestorUserData()
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.Experimental.ITransitionAnimations.Start(System.Single, System.Single, System.Int32, System.Action<UnityEngine.UIElements.VisualElement, System.Single>)
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.Experimental.ITransitionAnimations.Start(UnityEngine.Rect, UnityEngine.Rect, System.Int32, System.Action<UnityEngine.UIElements.VisualElement, UnityEngine.Rect>)
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.Experimental.ITransitionAnimations.Start(UnityEngine.Color, UnityEngine.Color, System.Int32, System.Action<UnityEngine.UIElements.VisualElement, UnityEngine.Color>)
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.Experimental.ITransitionAnimations.Start(UnityEngine.Vector3, UnityEngine.Vector3, System.Int32, System.Action<UnityEngine.UIElements.VisualElement, UnityEngine.Vector3>)
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.Experimental.ITransitionAnimations.Start(UnityEngine.Vector2, UnityEngine.Vector2, System.Int32, System.Action<UnityEngine.UIElements.VisualElement, UnityEngine.Vector2>)
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.Experimental.ITransitionAnimations.Start(UnityEngine.Quaternion, UnityEngine.Quaternion, System.Int32, System.Action<UnityEngine.UIElements.VisualElement, UnityEngine.Quaternion>)
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.Experimental.ITransitionAnimations.Start(UnityEngine.UIElements.Experimental.StyleValues, UnityEngine.UIElements.Experimental.StyleValues, System.Int32)
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.Experimental.ITransitionAnimations.Start(System.Func<UnityEngine.UIElements.VisualElement, System.Single>, System.Single, System.Int32, System.Action<UnityEngine.UIElements.VisualElement, System.Single>)
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.Experimental.ITransitionAnimations.Start(System.Func<UnityEngine.UIElements.VisualElement, UnityEngine.Rect>, UnityEngine.Rect, System.Int32, System.Action<UnityEngine.UIElements.VisualElement, UnityEngine.Rect>)
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.Experimental.ITransitionAnimations.Start(System.Func<UnityEngine.UIElements.VisualElement, UnityEngine.Color>, UnityEngine.Color, System.Int32, System.Action<UnityEngine.UIElements.VisualElement, UnityEngine.Color>)
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.Experimental.ITransitionAnimations.Start(System.Func<UnityEngine.UIElements.VisualElement, UnityEngine.Vector3>, UnityEngine.Vector3, System.Int32, System.Action<UnityEngine.UIElements.VisualElement, UnityEngine.Vector3>)
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.Experimental.ITransitionAnimations.Start(System.Func<UnityEngine.UIElements.VisualElement, UnityEngine.Vector2>, UnityEngine.Vector2, System.Int32, System.Action<UnityEngine.UIElements.VisualElement, UnityEngine.Vector2>)
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.Experimental.ITransitionAnimations.Start(System.Func<UnityEngine.UIElements.VisualElement, UnityEngine.Quaternion>, UnityEngine.Quaternion, System.Int32, System.Action<UnityEngine.UIElements.VisualElement, UnityEngine.Quaternion>)
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.Experimental.ITransitionAnimations.Start(UnityEngine.UIElements.Experimental.StyleValues, System.Int32)
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.Experimental.ITransitionAnimations.Layout(UnityEngine.Rect, System.Int32)
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.Experimental.ITransitionAnimations.TopLeft(UnityEngine.Vector2, System.Int32)
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.Experimental.ITransitionAnimations.Size(UnityEngine.Vector2, System.Int32)
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.Experimental.ITransitionAnimations.Scale(System.Single, System.Int32)
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.Experimental.ITransitionAnimations.Position(UnityEngine.Vector3, System.Int32)
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.Experimental.ITransitionAnimations.Rotation(UnityEngine.Quaternion, System.Int32)
    VisualElement.Add(VisualElement)
    VisualElement.Insert(Int32, VisualElement)
    VisualElement.Remove(VisualElement)
    VisualElement.RemoveAt(Int32)
    VisualElement.Clear()
    VisualElement.ElementAt(Int32)
    VisualElement.IndexOf(VisualElement)
    VisualElement.Children()
    UnityEngine.UIElements.VisualElement.Sort(System.Comparison<UnityEngine.UIElements.VisualElement>)
    VisualElement.BringToFront()
    VisualElement.SendToBack()
    VisualElement.PlaceBehind(VisualElement)
    VisualElement.PlaceInFront(VisualElement)
    VisualElement.RemoveFromHierarchy()
    UnityEngine.UIElements.VisualElement.GetFirstOfType<T>()
    UnityEngine.UIElements.VisualElement.GetFirstAncestorOfType<T>()
    VisualElement.Contains(VisualElement)
    VisualElement.FindCommonAncestor(VisualElement)
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IVisualElementScheduler.Execute(System.Action<UnityEngine.UIElements.TimerState>)
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IVisualElementScheduler.Execute(System.Action)
    VisualElement.viewDataKey
    VisualElement.userData
    UnityEngine.UIElements.VisualElement.canGrabFocus
    UnityEngine.UIElements.VisualElement.focusController
    VisualElement.usageHints
    VisualElement.transform
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.ITransform.position
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.ITransform.rotation
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.ITransform.scale
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.ITransform.matrix
    VisualElement.layout
    VisualElement.contentRect
    VisualElement.paddingRect
    VisualElement.worldBound
    VisualElement.localBound
    VisualElement.worldTransform
    VisualElement.pickingMode
    VisualElement.name
    VisualElement.enabledInHierarchy
    VisualElement.enabledSelf
    VisualElement.visible
    VisualElement.generateVisualContent
    VisualElement.experimental
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IExperimentalFeatures.animation
    VisualElement.hierarchy
    UnityEngine.UIElements.VisualElement.cacheAsBitmap
    VisualElement.parent
    VisualElement.panel
    VisualElement.visualTreeAssetSource
    UnityEngine.UIElements.VisualElement.Item[System.Int32]
    VisualElement.childCount
    VisualElement.schedule
    VisualElement.style
    VisualElement.customStyle
    VisualElement.styleSheets
    VisualElement.tooltip
    VisualElement.resolvedStyle
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.alignContent
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.alignItems
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.alignSelf
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.backgroundColor
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.backgroundImage
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.borderBottomColor
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.borderBottomLeftRadius
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.borderBottomRightRadius
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.borderBottomWidth
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.borderLeftColor
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.borderLeftWidth
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.borderRightColor
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.borderRightWidth
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.borderTopColor
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.borderTopLeftRadius
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.borderTopRightRadius
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.borderTopWidth
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.bottom
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.color
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.display
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.flexBasis
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.flexDirection
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.flexGrow
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.flexShrink
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.flexWrap
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.fontSize
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.height
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.justifyContent
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.left
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.letterSpacing
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.marginBottom
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.marginLeft
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.marginRight
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.marginTop
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.maxHeight
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.maxWidth
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.minHeight
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.minWidth
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.opacity
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.paddingBottom
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.paddingLeft
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.paddingRight
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.paddingTop
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.position
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.right
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.rotate
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.scale
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.textOverflow
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.top
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.transformOrigin
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.transitionDelay
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.transitionDuration
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.transitionProperty
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.transitionTimingFunction
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.translate
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.unityBackgroundImageTintColor
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.unityBackgroundScaleMode
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.unityFont
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.unityFontDefinition
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.unityFontStyleAndWeight
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.unityParagraphSpacing
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.unitySliceBottom
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.unitySliceLeft
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.unitySliceRight
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.unitySliceTop
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.unityTextAlign
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.unityTextOutlineColor
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.unityTextOutlineWidth
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.unityTextOverflowPosition
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.visibility
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.whiteSpace
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.width
    UnityEngine.UIElements.VisualElement.UnityEngine.UIElements.IResolvedStyle.wordSpacing
    Focusable.Blur()
    Focusable.focusable
    Focusable.tabIndex
    Focusable.delegatesFocus
    UnityEngine.UIElements.CallbackEventHandler.RegisterCallback<TEventType>(UnityEngine.UIElements.EventCallback<TEventType>, UnityEngine.UIElements.TrickleDown)
    UnityEngine.UIElements.CallbackEventHandler.RegisterCallback<TEventType, TUserArgsType>(UnityEngine.UIElements.EventCallback<TEventType, TUserArgsType>, TUserArgsType, UnityEngine.UIElements.TrickleDown)
    UnityEngine.UIElements.CallbackEventHandler.UnregisterCallback<TEventType>(UnityEngine.UIElements.EventCallback<TEventType>, UnityEngine.UIElements.TrickleDown)
    UnityEngine.UIElements.CallbackEventHandler.UnregisterCallback<TEventType, TUserArgsType>(UnityEngine.UIElements.EventCallback<TEventType, TUserArgsType>, UnityEngine.UIElements.TrickleDown)
    CallbackEventHandler.HandleEvent(EventBase)
    CallbackEventHandler.HasTrickleDownHandlers()
    CallbackEventHandler.HasBubbleUpHandlers()
    CallbackEventHandler.ExecuteDefaultActionAtTarget(EventBase)
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: Unity.AppUI.UI
    Syntax
    public class GridView : BindableElement, IEventHandler, IStylePropertyAnimations, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, IResolvedStyle, IBindable, ISerializationCallbackReceiver

    Constructors

    GridView()

    Creates a GridView with all default properties. The itemsSource, itemHeight, makeItem and bindItem properties must all be set for the GridView to function properly.

    Declaration
    public GridView()

    GridView(IList, Func<VisualElement>, Action<VisualElement, Int32>)

    Constructs a GridView, with all required properties provided.

    Declaration
    public GridView(IList itemsSource, Func<VisualElement> makeItem, Action<VisualElement, int> bindItem)
    Parameters
    Type Name Description
    IList itemsSource

    The list of items to use as a data source.

    Func<VisualElement> makeItem

    The factory method to call to create a display item. The method should return a VisualElement that can be bound to a data item.

    Action<VisualElement, Int32> bindItem

    The method to call to bind a data item to a display item. The method receives as parameters the display item to bind, and the index of the data item to bind it to.

    Fields

    ussClassName

    The USS class name for GridView elements.

    Declaration
    public const string ussClassName = "appui-grid-view"
    Field Value
    Type Description
    String
    Remarks

    Unity adds this USS class to every instance of the GridView element. Any styling applied to this class affects every GridView located beside, or below the stylesheet in the visual tree.

    Properties

    bindItem

    Callback for binding a data item to the visual element.

    Declaration
    public Action<VisualElement, int> bindItem { get; set; }
    Property Value
    Type Description
    Action<VisualElement, Int32>
    Remarks

    The method called by this callback receives the VisualElement to bind, and the index of the element to bind it to.

    columnCount

    The number of columns for this grid.

    Declaration
    public int columnCount { get; set; }
    Property Value
    Type Description
    Int32

    contentContainer

    Returns the content container for the GridView. Because the GridView control automatically manages its content, this always returns null.

    Declaration
    public override VisualElement contentContainer { get; }
    Property Value
    Type Description
    VisualElement
    Overrides
    VisualElement.contentContainer

    isSelecting

    Returns true if the soft-selection is in progress.

    Declaration
    public bool isSelecting { get; }
    Property Value
    Type Description
    Boolean

    itemHeight

    The height of a single item in the list, in pixels.

    Declaration
    public int itemHeight { get; set; }
    Property Value
    Type Description
    Int32
    Remarks

    GridView requires that all visual elements have the same height so that it can calculate the scroller size.

    This property must be set for the list view to function.

    itemsSource

    The data source for list items.

    Declaration
    public IList itemsSource { get; set; }
    Property Value
    Type Description
    IList
    Remarks

    This list contains the items that the GridView displays.

    This property must be set for the list view to function.

    itemWidth

    Declaration
    public float itemWidth { get; }
    Property Value
    Type Description
    Single

    makeItem

    Callback for constructing the VisualElement that is the template for each recycled and re-bound element in the list.

    Declaration
    public Func<VisualElement> makeItem { get; set; }
    Property Value
    Type Description
    Func<VisualElement>
    Remarks

    This callback needs to call a function that constructs a blank VisualElement that is bound to an element from the list.

    The GridView automatically creates enough elements to fill the visible area, and adds more if the area is expanded. As the user scrolls, the GridView cycles elements in and out as they appear or disappear.

    This property must be set for the list view to function.

    operationMask

    A mask describing available operations in this GridView when the user interacts with it.

    Declaration
    public GridView.GridOperations operationMask { get; set; }
    Property Value
    Type Description
    GridView.GridOperations

    preventScrollWithModifiers

    Prevents the grid view from scrolling when the user presses a modifier key at the same time as scrolling.

    Declaration
    public bool preventScrollWithModifiers { get; set; }
    Property Value
    Type Description
    Boolean

    resolvedItemHeight

    The computed pixel-aligned height for the list elements.

    Declaration
    public float resolvedItemHeight { get; }
    Property Value
    Type Description
    Single
    Remarks

    This value changes depending on the current panel's DPI scaling.

    See Also
    itemHeight

    resolvedItemWidth

    Declaration
    public float resolvedItemWidth { get; }
    Property Value
    Type Description
    Single

    selectedIds

    Returns the IDs of selected items in the data source. Always returns an enumerable, even if no item is selected, or a single item is selected.

    Declaration
    public IEnumerable<int> selectedIds { get; }
    Property Value
    Type Description
    IEnumerable<Int32>

    selectedIndex

    Returns or sets the selected item's index in the data source. If multiple items are selected, returns the first selected item's index. If multiple items are provided, sets them all as selected.

    Declaration
    public int selectedIndex { get; set; }
    Property Value
    Type Description
    Int32

    selectedIndices

    Returns the indices of selected items in the data source. Always returns an enumerable, even if no item is selected, or a single item is selected.

    Declaration
    public IEnumerable<int> selectedIndices { get; }
    Property Value
    Type Description
    IEnumerable<Int32>

    selectedItem

    Returns the selected item from the data source. If multiple items are selected, returns the first selected item.

    Declaration
    public object selectedItem { get; }
    Property Value
    Type Description
    Object

    selectedItems

    Returns the selected items from the data source. Always returns an enumerable, even if no item is selected, or a single item is selected.

    Declaration
    public IEnumerable<object> selectedItems { get; }
    Property Value
    Type Description
    IEnumerable<Object>

    selectionType

    Controls the selection type.

    Declaration
    public SelectionType selectionType { get; set; }
    Property Value
    Type Description
    SelectionType
    Remarks

    You can set the GridView to make one item selectable at a time, make multiple items selectable, or disable selections completely.

    When you set the GridView to disable selections, any current selection is cleared.

    showBorder

    Enable this property to display a border around the GridView.

    Declaration
    public bool showBorder { get; set; }
    Property Value
    Type Description
    Boolean
    Remarks

    If set to true, a border appears around the ScrollView.

    unbindItem

    Callback for unbinding a data item from the VisualElement.

    Declaration
    public Action<VisualElement, int> unbindItem { get; set; }
    Property Value
    Type Description
    Action<VisualElement, Int32>
    Remarks

    The method called by this callback receives the VisualElement to unbind, and the index of the element to unbind it from.

    Methods

    AddToSelection(Int32)

    Adds an item to the collection of selected items.

    Declaration
    public void AddToSelection(int index)
    Parameters
    Type Name Description
    Int32 index

    Item index.

    CancelDrag()

    Cancel drag operation.

    Declaration
    public void CancelDrag()

    ClearSelection()

    Deselects any selected items.

    Declaration
    public void ClearSelection()

    ClearSelectionWithoutNotify()

    Declaration
    public void ClearSelectionWithoutNotify()

    GetIndexByPosition(Vector2)

    Returns the index of the item at the given position.

    Declaration
    public int GetIndexByPosition(Vector2 localPosition)
    Parameters
    Type Name Description
    Vector2 localPosition

    The position of the item relative to the top left corner of the grid.

    Returns
    Type Description
    Int32

    The index of the item at the given position.

    Remarks

    The position is relative to the top left corner of the grid. No check is made to see if the index is valid.

    Refresh()

    Clears the GridView, recreates all visible visual elements, and rebinds all items.

    Declaration
    public void Refresh()
    Remarks

    Call this method whenever the data source changes.

    RemoveFromSelection(Int32)

    Removes an item from the collection of selected items.

    Declaration
    public void RemoveFromSelection(int index)
    Parameters
    Type Name Description
    Int32 index

    The item index.

    ScrollToItem(Int32)

    Scrolls to a specific item index and makes it visible.

    Declaration
    public void ScrollToItem(int index)
    Parameters
    Type Name Description
    Int32 index

    Item index to scroll to. Specify -1 to make the last item visible.

    SetSelection(IEnumerable<Int32>)

    Sets a collection of selected items.

    Declaration
    public void SetSelection(IEnumerable<int> indices)
    Parameters
    Type Name Description
    IEnumerable<Int32> indices

    The collection of the indices of the items to be selected.

    SetSelection(Int32)

    Sets the currently selected item.

    Declaration
    public void SetSelection(int index)
    Parameters
    Type Name Description
    Int32 index

    The item index.

    SetSelectionWithoutNotify(IEnumerable<Int32>)

    Sets a collection of selected items without triggering a selection change callback.

    Declaration
    public void SetSelectionWithoutNotify(IEnumerable<int> indices)
    Parameters
    Type Name Description
    IEnumerable<Int32> indices

    The collection of items to be selected.

    Events

    contextClicked

    Callback triggered when the user right-clicks on an item.

    Declaration
    public event Action<PointerDownEvent> contextClicked
    Event Type
    Type Description
    Action<PointerDownEvent>
    Remarks

    This callback receives an enumerable that contains the item or items selected.

    doubleClicked

    Callback triggered when the user double-clicks on an item.

    Declaration
    public event Action<int> doubleClicked
    Event Type
    Type Description
    Action<Int32>

    dragCanceled

    Callback triggered when drag has been canceled.

    Declaration
    public event Action dragCanceled
    Event Type
    Type Description
    Action

    dragFinished

    Callback triggered when drag has finished.

    Declaration
    public event Action<PointerUpEvent> dragFinished
    Event Type
    Type Description
    Action<PointerUpEvent>

    dragStarted

    Callback triggered when drag has started.

    Declaration
    public event Action<PointerMoveEvent> dragStarted
    Event Type
    Type Description
    Action<PointerMoveEvent>

    dragUpdated

    Callback triggered when items are dragged.

    Declaration
    public event Action<PointerMoveEvent> dragUpdated
    Event Type
    Type Description
    Action<PointerMoveEvent>

    itemsChosen

    Callback triggered when the user acts on a selection of one or more items, for example by double-clicking or pressing Enter.

    Declaration
    public event Action<IEnumerable<object>> itemsChosen
    Event Type
    Type Description
    Action<IEnumerable<Object>>
    Remarks

    This callback receives an enumerable that contains the item or items chosen.

    selectionChanged

    Callback triggered when the selection changes.

    Declaration
    public event Action<IEnumerable<object>> selectionChanged
    Event Type
    Type Description
    Action<IEnumerable<Object>>
    Remarks

    This callback receives an enumerable that contains the item or items selected.

    Explicit Interface Implementations

    ISerializationCallbackReceiver.OnAfterDeserialize()

    Declaration
    void ISerializationCallbackReceiver.OnAfterDeserialize()
    Implements
    ISerializationCallbackReceiver.OnAfterDeserialize()

    ISerializationCallbackReceiver.OnBeforeSerialize()

    Declaration
    void ISerializationCallbackReceiver.OnBeforeSerialize()
    Implements
    ISerializationCallbackReceiver.OnBeforeSerialize()

    Extension Methods

    VisualElementExtensions.FindNavController(VisualElement)
    VisualElementExtensions.GetContext(VisualElement)
    VisualElementExtensions.GetChildren<T>(VisualElement, Boolean)
    VisualElementExtensions.GetPreferredTooltipPlacement(VisualElement)
    VisualElementExtensions.SetPreferredTooltipPlacement(VisualElement, PopoverPlacement)
    VisualElementExtensions.GetTooltipTemplate(VisualElement)
    VisualElementExtensions.SetTooltipTemplate(VisualElement, VisualElement)
    VisualElementExtensions.GetWorldBoundingBox(VisualElement)
    VisualElementExtensions.GetContextProvider<T>(VisualElement)
    VisualElementExtensions.GetContext<T>(VisualElement)
    VisualElementExtensions.GetSelfContext<T>(VisualElement)
    VisualElementExtensions.ProvideContext<T>(VisualElement, T)
    VisualElementExtensions.IsContextProvider<T>(VisualElement)
    VisualElementExtensions.RegisterContextChangedCallback<T>(VisualElement, EventCallback<ContextChangedEvent<T>>)
    VisualElementExtensions.UnregisterContextChangedCallback<T>(VisualElement, EventCallback<ContextChangedEvent<T>>)
    In This Article
    • Constructors
      • GridView()
      • GridView(IList, Func<VisualElement>, Action<VisualElement, Int32>)
    • Fields
      • ussClassName
    • Properties
      • bindItem
      • columnCount
      • contentContainer
      • isSelecting
      • itemHeight
      • itemsSource
      • itemWidth
      • makeItem
      • operationMask
      • preventScrollWithModifiers
      • resolvedItemHeight
      • resolvedItemWidth
      • selectedIds
      • selectedIndex
      • selectedIndices
      • selectedItem
      • selectedItems
      • selectionType
      • showBorder
      • unbindItem
    • Methods
      • AddToSelection(Int32)
      • CancelDrag()
      • ClearSelection()
      • ClearSelectionWithoutNotify()
      • GetIndexByPosition(Vector2)
      • Refresh()
      • RemoveFromSelection(Int32)
      • ScrollToItem(Int32)
      • SetSelection(IEnumerable<Int32>)
      • SetSelection(Int32)
      • SetSelectionWithoutNotify(IEnumerable<Int32>)
    • Events
      • contextClicked
      • doubleClicked
      • dragCanceled
      • dragFinished
      • dragStarted
      • dragUpdated
      • itemsChosen
      • selectionChanged
    • Explicit Interface Implementations
      • ISerializationCallbackReceiver.OnAfterDeserialize()
      • ISerializationCallbackReceiver.OnBeforeSerialize()
    • Extension Methods
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023