Table of Contents

Class FlexalonVirtualizer

Namespace
Flexalon
Assembly
Flexalon.dll

Replaces the children of a scroll-content layout with virtual nodes, allocating GameObjects only where that layout overlaps the viewport. Disabling clears generated content while retaining data and callbacks for re-enabling.

[ExecuteAlways]
[AddComponentMenu("Flexalon/Flexalon Virtualizer")]
public class FlexalonVirtualizer : MonoBehaviour
Inheritance
object
Object
Component
Behaviour
MonoBehaviour
FlexalonVirtualizer

Properties

AllocateMargin

The extra distance added to each side of the viewport in which allocation is triggered. The smaller of this value and Recycle Margin is used on each axis. When an unallocated object enters this boundary, all unallocated objects overlapping the midpoint between the effective margins are allocated together. Equal margins disable batching ahead.

public Vector3 AllocateMargin { get; set; }

Property Value

Vector3

AllocatedCount

The number of instantiated objects currently assigned to data entries.

public int AllocatedCount { get; }

Property Value

int

BindData

Called when a GameObject is assigned to a data entry, with index, data, and GameObject.

public FlexalonVirtualizer.BindDelegate BindData { get; set; }

Property Value

FlexalonVirtualizer.BindDelegate

CreateInstance

Creates a GameObject when the recycled pool is empty. When null, Prefab is instantiated.

public Func<GameObject> CreateInstance { get; set; }

Property Value

Func<GameObject>

DestroyInstance

Destroys a GameObject when it leaves the recycled pool. When null, Unity's Destroy is used in play mode and DestroyImmediate in edit mode.

public Action<GameObject> DestroyInstance { get; set; }

Property Value

Action<GameObject>

InitializeVirtualObject

Initializes each virtual object with its index and data when entries are created or refreshed. When Prefab is set, its layout settings are copied before this callback is invoked for the item.

public FlexalonVirtualizer.InitializeDelegate InitializeVirtualObject { get; set; }

Property Value

FlexalonVirtualizer.InitializeDelegate

Layout

The scroll-content layout whose children are virtualized.

public FlexalonLayoutBase Layout { get; set; }

Property Value

FlexalonLayoutBase

MaxPoolSize

Maximum number of inactive recycled GameObjects retained for reuse.

public int MaxPoolSize { get; set; }

Property Value

int

Prefab

Template used for virtual layout settings and default instance creation. Optional when InitializeVirtualObject and CreateInstance are both set.

public FlexalonObject Prefab { get; set; }

Property Value

FlexalonObject

RecycleMargin

The extra distance added to each side of the viewport before allocated objects are recycled. The larger of this value and Allocate Margin is used on each axis. When an allocated object leaves this boundary, all objects outside the midpoint between the effective allocation and recycling margins are recycled together.

public Vector3 RecycleMargin { get; set; }

Property Value

Vector3

RecycledCount

The number of instantiated objects currently available for reuse.

public int RecycledCount { get; }

Property Value

int

UnbindData

Called when a GameObject is released from a data entry, with index, data, and GameObject.

public FlexalonVirtualizer.BindDelegate UnbindData { get; set; }

Property Value

FlexalonVirtualizer.BindDelegate

UniformItems

Reuses item allocation and placement without checking compatibility. Enable when instances and virtual items can occupy the same layout slots. Defaults to false. Transfers the solved result without requesting layout on the list. Pending layout inside an item is preserved; binding runs after the swap and may invalidate it normally.

public bool UniformItems { get; set; }

Property Value

bool

Viewport

The GameObject whose Flexalon node defines the visible bounds.

public GameObject Viewport { get; set; }

Property Value

GameObject

VirtualCount

The total number of virtual nodes, one for each data entry.

public int VirtualCount { get; }

Property Value

int

Methods

Clear()

Destroys all allocated objects and virtual nodes, and clears the current data.

public void Clear()

NotifyDataAdded(int, int)

Notifies the virtualizer that entries were inserted into the current data list. Mutate the list first, then call this method with the inserted range.

public void NotifyDataAdded(int index, int count = 1)

Parameters

index int
count int

NotifyDataChanged(int, int)

Notifies the virtualizer that entries were changed and need to be reinitialized and rebound.

public void NotifyDataChanged(int index, int count = 1)

Parameters

index int
count int

NotifyDataRemoved(int, int)

Notifies the virtualizer that entries were removed from the current data list. Mutate the list first, then call this method with the removed range's former index.

public void NotifyDataRemoved(int index, int count = 1)

Parameters

index int
count int

SetData(IList)

Replaces the current data and creates one virtual layout node per entry.

public void SetData(IList data)

Parameters

data IList

The list of entries represented by the virtual layout nodes.