Class FancyScrollRect<TItemData, TContext>
ScrollRect スタイルのスクロールビューを実装するための抽象基底クラス. 無限スクロールおよびスナップには対応していません. Context が不要な場合は 代わりに FancyScrollRect<TItemData> を使用します.
Inheritance
Inherited Members
Namespace: FancyScrollView
Assembly: FancyScrollView.dll
Syntax
[RequireComponent(typeof(Scroller))]
public abstract class FancyScrollRect<TItemData, TContext> : FancyScrollView<TItemData, TContext> where TContext : class, IFancyScrollRectContext, new()
Type Parameters
| Name | Description |
|---|---|
| TItemData | アイテムのデータ型. |
| TContext | Context の型. |
Fields
paddingHead
コンテンツ先頭の余白.
Declaration
[SerializeField]
protected float paddingHead
Field Value
| Type | Description |
|---|---|
| System.Single |
paddingTail
コンテンツ末尾の余白.
Declaration
[SerializeField]
protected float paddingTail
Field Value
| Type | Description |
|---|---|
| System.Single |
reuseCellMarginCount
スクロール中にセルが再利用されるまでの余白のセル数.
Declaration
[SerializeField]
protected float reuseCellMarginCount
Field Value
| Type | Description |
|---|---|
| System.Single |
Remarks
0 を指定するとセルが完全に隠れた直後に再利用されます.
1 以上を指定すると, そのセル数だけ余分にスクロールしてから再利用されます.
spacing
スクロール軸方向のセル同士の余白.
Declaration
[SerializeField]
protected float spacing
Field Value
| Type | Description |
|---|---|
| System.Single |
Properties
CellSize
セルのサイズ.
Declaration
protected abstract float CellSize { get; }
Property Value
| Type | Description |
|---|---|
| System.Single |
Scrollable
スクロール可能かどうか.
Declaration
protected virtual bool Scrollable { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Remarks
アイテム数が十分少なくビューポート内に全てのセルが収まっている場合は false, それ以外は true になります.
Scroller
スクロール位置を制御する Scroller のインスタンス.
Declaration
protected Scroller Scroller { get; }
Property Value
| Type | Description |
|---|---|
| Scroller |
Remarks
Scroller のスクロール位置を変更する際は必ず ToScrollerPosition(Single) を使用して変換した位置を使用してください.
Methods
AdjustCellIntervalAndScrollOffset()
指定された設定を実現するための cellInterval と scrollOffset を計算して適用します.
Declaration
protected void AdjustCellIntervalAndScrollOffset()
Initialize()
Declaration
protected override void Initialize()
Overrides
JumpTo(Int32, Single)
指定したアイテムの位置までジャンプします.
Declaration
protected virtual void JumpTo(int itemIndex, float alignment = 0.5F)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | itemIndex | アイテムのインデックス. |
| System.Single | alignment | ビューポート内におけるセル位置の基準. 0f(先頭) ~ 1f(末尾). |
OnValidate()
Declaration
protected virtual void OnValidate()
Refresh()
Declaration
protected override void Refresh()
Overrides
RefreshScroller()
Scroller の各種状態を更新します.
Declaration
protected void RefreshScroller()
Relayout()
Declaration
protected override void Relayout()
Overrides
ScrollTo(Int32, Single, Ease, Single, Action)
指定したアイテムの位置まで移動します.
Declaration
protected virtual void ScrollTo(int index, float duration, Ease easing, float alignment = 0.5F, Action onComplete = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | アイテムのインデックス. |
| System.Single | duration | 移動にかける秒数. |
| Ease | easing | 移動に使用するイージング. |
| System.Single | alignment | ビューポート内におけるセル位置の基準. 0f(先頭) ~ 1f(末尾). |
| System.Action | onComplete | 移動が完了した際に呼び出されるコールバック. |
ScrollTo(Int32, Single, Single, Action)
指定したアイテムの位置まで移動します.
Declaration
protected virtual void ScrollTo(int index, float duration, float alignment = 0.5F, Action onComplete = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | アイテムのインデックス. |
| System.Single | duration | 移動にかける秒数. |
| System.Single | alignment | ビューポート内におけるセル位置の基準. 0f(先頭) ~ 1f(末尾). |
| System.Action | onComplete | 移動が完了した際に呼び出されるコールバック. |
ToFancyScrollViewPosition(Single)
Scroller が扱うスクロール位置を FancyScrollRect<TItemData, TContext> が扱うスクロール位置に変換します.
Declaration
protected float ToFancyScrollViewPosition(float position)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Single | position | Scroller が扱うスクロール位置. |
Returns
| Type | Description |
|---|---|
| System.Single | FancyScrollRect<TItemData, TContext> が扱うスクロール位置. |
ToScrollerPosition(Single)
FancyScrollRect<TItemData, TContext> が扱うスクロール位置を Scroller が扱うスクロール位置に変換します.
Declaration
protected float ToScrollerPosition(float position)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Single | position | FancyScrollRect<TItemData, TContext> が扱うスクロール位置. |
Returns
| Type | Description |
|---|---|
| System.Single | Scroller が扱うスクロール位置. |
ToScrollerPosition(Single, Single)
FancyScrollRect<TItemData, TContext> が扱うスクロール位置を Scroller が扱うスクロール位置に変換します.
Declaration
protected float ToScrollerPosition(float position, float alignment = 0.5F)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Single | position | FancyScrollRect<TItemData, TContext> が扱うスクロール位置. |
| System.Single | alignment | ビューポート内におけるセル位置の基準. 0f(先頭) ~ 1f(末尾). |
Returns
| Type | Description |
|---|---|
| System.Single | Scroller が扱うスクロール位置. |
UpdateContents(IList<TItemData>)
Declaration
protected override void UpdateContents(IList<TItemData> items)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IList<TItemData> | items |
Overrides
UpdatePosition(Single)
スクロール位置を更新します.
Declaration
protected void UpdatePosition(float position)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Single | position | スクロール位置. |
UpdateScrollbarSize(Single)
ビューポートとコンテンツの長さに基づいてスクロールバーのサイズを更新します.
Declaration
protected void UpdateScrollbarSize(float viewportLength)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Single | viewportLength | ビューポートのサイズ. |