Class MasonryGridView
A view containing Masonry grid layout.
Inheritance
Implements
Inherited Members
Namespace: Unity.AppUI.UI
Assembly: Unity.AppUI.dll
Syntax
public class MasonryGridView : BaseGridView, IEventHandler, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, IResolvedStyle, IBindable, ISerializationCallbackReceiver
Constructors
MasonryGridView()
Constructs a new MasonryGridView.
Declaration
public MasonryGridView()
Fields
columnContainerUssClassName
The column container USS class name of a MasonryGridView.
Declaration
public static readonly string columnContainerUssClassName
Field Value
| Type | Description |
|---|---|
| string |
columnUssClassName
The columns USS class name of a MasonryGridView.
Declaration
public static readonly string columnUssClassName
Field Value
| Type | Description |
|---|---|
| string |
masonryGridViewUssClassName
The USS class name of a MasonryGridView.
Declaration
public static readonly string masonryGridViewUssClassName
Field Value
| Type | Description |
|---|---|
| string |
Properties
pack
Whether to pack the items (the grid will try to take the minimum space possible by distributing the items in the columns).
Declaration
public bool pack { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Methods
ApplySelectedState()
Set the selected visual state on items.
Declaration
protected override void ApplySelectedState()
Overrides
GetIndexByWorldPosition(Vector2)
Returns the index of the item at the given position.
Declaration
public override int GetIndexByWorldPosition(Vector2 worldPosition)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | worldPosition | The position of the item in the world-space. |
Returns
| Type | Description |
|---|---|
| int | The index of the item at the given position. |
Overrides
Remarks
The position is relative to the top left corner of the grid. No check is made to see if the index is valid.
GetVisualElementInternal(int)
Implement this method to return the VisualElement at the specified index.
Declaration
protected override VisualElement GetVisualElementInternal(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | The index of the VisualElement to return. |
Returns
| Type | Description |
|---|---|
| VisualElement | The VisualElement at the specified index. |
Overrides
OnContainerHeightChanged(float)
Callback called when the ScrollView container height changes.
Declaration
protected override void OnContainerHeightChanged(float height)
Parameters
| Type | Name | Description |
|---|---|---|
| float | height | The new height of the container. |
Overrides
OnCustomStyleResolved(CustomStyleResolvedEvent)
Method to implement to handle the custom style resolved event.
Declaration
protected override void OnCustomStyleResolved(CustomStyleResolvedEvent e)
Parameters
| Type | Name | Description |
|---|---|---|
| CustomStyleResolvedEvent | e | The custom style resolved event. |
Overrides
OnScroll(float)
Callback called when the scroll value changes.
Declaration
protected override void OnScroll(float offset)
Parameters
| Type | Name | Description |
|---|---|---|
| float | offset | The new scroll offset. |
Overrides
Remarks
You can also call this method one frame your Refresh() implementation to ensure the visual state of the grid is updated correctly.
Refresh()
Clears the GridView, recreates all visible visual elements, and rebinds all items.
Declaration
public override void Refresh()
Overrides
Remarks
Call this method whenever the data source changes.
ScrollToItem(int)
Scrolls to a specific item index and makes it visible.
Declaration
public override void ScrollToItem(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | Item index to scroll to. Specify -1 to make the last item visible. |