Click or drag to resize

frame8.Logic.Misc.Visual.UI.ScrollRectItemsAdapter Namespace

 
Classes
  ClassDescription
Public classAbstractViewsHolder
Class representing the concept of a Views Holder, i.e. a class that references some views and the id of the data displayed by those views. Usually, the root and its child views, once created, don't change, but ItemIndex does, after which the views will change their data.
Public classBaseItemViewsHolder
Public classBaseParams

Input params to be passed to Init

This can be used Monobehaviour's field and exposed via inspector (most common case)

Or can be manually constructed, depending on what's easier in your context

Public classBaseParamsEffects
Public classBaseParamsOptimization
Public classBaseParamsWithPrefab
Custom params containing a single prefab. ItemPrefabSize is calculated on first accessing and invalidated each time InitIfNeeded(ISRIA) is called.
Public classItemsDescriptor
Public classReadOnlyAttribute
Public classSnapper8
Public classSRIATParams, TItemViewsHolder

Old name: ScrollRectItemsAdapter8 (renamed in v3.0 to SRIA)

Base abstract component that you need to extend in order to provide an implementation for CreateViewsHolder(Int32) and UpdateViewsHolder(TItemViewsHolder). Should be attached instead of the Unity's ScrollRect component. Any views holder should extend BaseItemViewsHolder, so you can provide it as the generic parameter TItemViewsHolder when implementing SRIA. Extending BaseParams is optional. Based on your needs. Provide it as generic parameter TParams when implementing SRIA

How it works, in a nutshell (it's recommended to manually go through the example code in order to fully understand the mechanism):

1. create your own implementation of BaseItemViewsHolder, let's name it MyItemViewsHolder

2. create your own implementation of BaseParams (if needed), let's name it MyParams

3. create your own implementation of SRIA<MyParams, MyItemViewsHolder>, let's name it MyScrollRectItemsAdapter

4. instantiate MyScrollRectItemsAdapter

5. call MyScrollRectItemsAdapter.ResetItems(int) once (and any time your dataset is changed) and the following things will happen:

5.1. CollectItemsSizes(ItemCountChangeMode, Int32, Int32, ItemsDescriptor) will be called (which you can optionally implement to provide your own sizes, if known beforehand)

5.2. CreateViewsHolder(Int32) will be called for enough items to fill the viewport. Once a ViewsHolder is created, it'll be re-used when it goes off-viewport

- newOrRecycledViewsHolder.root will be null, so you need to instantiate your prefab, assign it and call newOrRecycledViewsHolder.CollectViews(). Alternatively, you can call its Init(GameObject, Int32, Boolean, Boolean) method, which can do a lot of things for you, mainly instantiate the prefab and (if you want) call CollectViews() for you

- after creation, only UpdateViewsHolder(TItemViewsHolder) will be called for it when its represented item changes and becomes visible

5.3. UpdateViewsHolder(TItemViewsHolder) will be called when an item is to be displayed or simply needs updating:

- use ItemIndex to get the item index, so you can retrieve its associated model from your data set (most common practice is to store the data list in your Params implementation)

- root is not null here (given the views holder was properly created in CreateViewsHolder(..)). It's assigned a valid object whose UI elements only need their values changed (common practice is to implement helper methods in the views holder that take the model and update the views themselves)

ResetItems(Int32, Boolean, Boolean) is also called when the viewport's size changes (like for orientation changes on mobile or window resizing on sandalone platforms)

*NOTE: No LayoutGroup (vertical/horizontal/grid) on content panel are allowed, since all the layouting is delegated to this adapter

Protected classSRIATParams, TItemViewsHolderNestingManager
Public classSRIAConst
Public classSRIADebugger
Public classUtils
Interfaces
  InterfaceDescription
Public interfaceISRIA
Contains commonly used members so that an SRIATParams, TItemViewsHolder instance can be referenced abstractly (since instances of derived generic classes cannot be referenced by a variable of base type).
Enumerations
  EnumerationDescription
Public enumerationBaseParamsContentGravity
Represents how often or when the optimizer does his core loop: checking for any items that need to be created, destroyed, disabled, displayed, recycled
Public enumerationBaseParamsOrientationEnum
Public enumerationItemCountChangeMode