使用说明instructions指示.pdf
USAGEINSTRUCTIONS
ScrollrectItemsAdapter8,BaseParamsandBaseItemViewsHolderarethe3coreclassesinoursmall
librarydedicatedtobothoptimizeaScrollViewandprogrammaticallymanageitscontents.
YoucanuseitbothforahorizontalandverticalScrollView.
ScrollrectItemsAdapter8it’sanclass,becauseyouneedtoprovidetheheightorwidth
(dependingifit’saverticalorhorizontalScrollRect)ofeachitem(viayourimplementationof
ScrollrectItemsAdapter8.GetItem[Height/Width](intindex)callback)andtopopulatetheviewswith
dataforeachitem(viayourimplementationof
ScrollrectItemsAdapter8.InitOrUpdateItemViewHolder(BaseItemViewsHolderviewsHolder)callback).
ItsrecommendedtomanuallygothroughexamplecodeprovidedinScrollRectItemsAdapterExample.cs
andSimpleTutorial.csinordertofullyunderstandthemechanism.You’llfinddetailedcommentsin
coreareas.Youmayevenusethisscriptdirectlywithoutimplementingyourown,insomesimple
scenarios.
(Somemayfinditmoreeasytoconsulttheexamplecode+scenedirectly,withoutreadingthistutorial)
IMPLEMENTATION
(Followthesestepswhileconstantlylookingathowit’sdoneintheexamplecodeinSimpleTutorial.cs
andoptionallyinScrollRectItemsAdapterExample.cs)
Here’sthenormalflowyou’llfollowafteryou’vecreatedaScrollViewusingGameObject-UI-Scroll
View:
1.createyourownimplementationofBaseItemViewsHolder,letsnameitMyItemViewsHolder
2.createyourownimplementationofBaseParams(ifneeded),letsnameitMyParams
3.createyourownimplementationofScrollRectItemsAdapter8MyParams,MyItemViewsHolder,lets
nameitMyScrollRectItemsAdapter
4.instantiateMyScrollRectItemsAdapter
5.callMyScrollRectItemsAdapter.ChangeItemCountTo(intcount)once(andanytimeyourdatasetis
changed)andtwothingswillhappen:
5.1.iftheScrollRecthasverticalscrolling,MyScrollRectItemsAdapter.GetItemHeight(intindex)
will