Click or drag to resize

ChatExample Class

This class demonstrates a basic chat implementation. A message can contain a text, image, or both
Inheritance Hierarchy
SystemObject
  Object
    Component
      Behaviour
        MonoBehaviour
          frame8.Logic.Misc.Visual.UI.ScrollRectItemsAdapterSRIAMyParams, ChatMessageViewsHolder
            frame8.ScrollRectItemsAdapter.ChatExampleChatExample

Namespace:  frame8.ScrollRectItemsAdapter.ChatExample
Assembly:  Assembly-CSharp (in Assembly-CSharp.dll) Version: 0.0.0.0
Syntax
C#
public class ChatExample : SRIA<MyParams, ChatMessageViewsHolder>

The ChatExample type exposes the following members.

Constructors
  NameDescription
Public methodChatExample
Top
Methods
  NameDescription
Protected methodCreateViewsHolder

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

(Overrides SRIATParams, TItemViewsHolderCreateViewsHolder(Int32).)
Protected methodOnBeforeRecycleOrDisableViewsHolder
Perfect place to clean the views in order to prepare them to be potentially recycled this frame or soon. newItemIndex will be -1 if the item will be disabled/destroyed instead of being recycled.
(Overrides SRIATParams, TItemViewsHolderOnBeforeRecycleOrDisableViewsHolder(TItemViewsHolder, Int32).)
Protected methodOnItemHeightChangedPreTwinPass
Only called for vertical ScrollRects. Called just before a "Twin" ComputeVisibility will execute. This can be used, for example, to disable a ContentSizeFitter on the item which was used to externally calculate the item's size in the current Twin ComputeVisibility pass
(Overrides SRIATParams, TItemViewsHolderOnItemHeightChangedPreTwinPass(TItemViewsHolder).)
Protected methodRebuildLayoutDueToScrollViewSizeChange

Called mainly when it's detected that the scroll view's size has changed. Marks everything for a layout rebuild and then calls Canvas.ForceUpdateCanvases().

IMPORTANT: Make sure to override MarkForRebuild in your views holder implementation if you have child layout groups and call LayoutRebuilder.MarkForRebuild() on them

(Overrides SRIATParams, TItemViewsHolderRebuildLayoutDueToScrollViewSizeChange.)
Protected methodStart (Overrides SRIATParams, TItemViewsHolderStart.)
Protected methodUpdate (Overrides SRIATParams, TItemViewsHolderUpdate.)
Protected methodUpdateViewsHolder

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

(Overrides SRIATParams, TItemViewsHolderUpdateViewsHolder(TItemViewsHolder).)
Top
Version Information

Optimized ScrollView Adapter

Supported in: 4.0, 3.0
See Also