/// Credit setchi (https://github.com/setchi) /// Sourced from - https://github.com/setchi/FancyScrollView namespace UnityEngine.UI.Extensions { /// /// のセルを実装するための抽象基底クラス. /// が不要な場合は /// 代わりに を使用します. /// /// アイテムのデータ型. /// の型. public abstract class FancyScrollRectCell : FancyCell where TContext : class, IFancyScrollRectContext, new() { /// public override void UpdatePosition(float position) { var (scrollSize, reuseMargin) = Context.CalculateScrollSize(); var normalizedPosition = (Mathf.Lerp(0f, scrollSize, position) - reuseMargin) / (scrollSize - reuseMargin * 2f); var start = 0.5f * scrollSize; var end = -start; UpdatePosition(normalizedPosition, Mathf.Lerp(start, end, position)); } /// /// このセルの位置を更新します. /// /// /// ビューポートの範囲で正規化されたスクロール位置. /// の値に基づいて /// 0.0 ~ 1.0 の範囲を超えた値が渡されることがあります. /// /// ローカル位置. protected virtual void UpdatePosition(float normalizedPosition, float localPosition) { transform.localPosition = Context.ScrollDirection == ScrollDirection.Horizontal ? new Vector2(-localPosition, 0) : new Vector2(0, localPosition); } } /// /// のセルを実装するための抽象基底クラス. /// /// アイテムのデータ型. /// public abstract class FancyScrollRectCell : FancyScrollRectCell { /// public sealed override void SetContext(FancyScrollRectContext context) => base.SetContext(context); } }