MainExample Class |
The main example implementation demonstrating common (not all) functionalities:
- using both a horizontal (also includes optional snapping) and a vertical ScrollView with a complex prefab,
- changing the item count, adding/removing to/from head/end of the list,
- expanding/collapsing an item, thus demonstrating the possibility of multiple sizes,
- smooth scrolling to an item & optionally doing an action after the animation is done,
- comparing the performance to the default implementation of a ScrollView,
- the use of ScrollbarFixer8
At the core, everything's the same as in other example implementations, so if something's not clear, check them (SimpleExample is a good start)
Namespace: Com.ForbiddenByte.OSA.Demos.Main
public class MainExample : OSA<MyParams, ClientItemViewsHolder>, ExpandCollapseOnClickISizeChangesHandler
The MainExample type exposes the following members.
Name | Description | |
---|---|---|
MainExample |
Name | Description | |
---|---|---|
CreateViewsHolder | Called when there are no recyclable views for itemIndex. Provide a new viewsholder instance for itemIndex. This is the place where you must initialize the viewsholder via Init(GameObject, Int32, Boolean, Boolean) shortcut or manually set its itemIndex, instantiate the prefab and call its CollectViews | |
OnDestroy | (Overrides OSATParams, TItemViewsHolderOnDestroy.) | |
OnExpandedStateChanged | ||
OnItemIndexChangedDueInsertOrRemove | This is overidden only so that the items' title will be updated to reflect its new index in case of Insert/Remove, because the index is not stored in the model If you don't store/care about the index of each item, you can omit this For more info, see OnItemIndexChangedDueInsertOrRemove(TItemViewsHolder, Int32, Boolean, Int32) | |
Start | (Overrides OSATParams, TItemViewsHolderStart.) | |
UpdateViewsHolder | Here the data in your model should be bound to the views. Use newOrRecycled.ItemIndex (ItemIndex) to retrieve its associated model Note that views holders are re-used (this is the main purpose of this adapter), so a views holder's views will contain data from its previously associated model and if, for example, you're downloading an image to be set as an icon, it makes sense to first clear the previous one (and probably temporarily replace it with a generic "Loading" image) Note that this is not called for items that will remain visible after an Insert or Remove operation is done |