/// Credit setchi (https://github.com/setchi)
/// Sourced from - https://github.com/setchi/FancyScrollView
namespace UnityEngine.UI.Extensions
{
///
/// のセルを実装するための抽象基底クラス.
/// が不要な場合は
/// 代わりに を使用します.
///
/// アイテムのデータ型.
/// の型.
public abstract class FancyGridViewCell : FancyScrollRectCell
where TContext : class, IFancyGridViewContext, new()
{
///
protected override void UpdatePosition(float normalizedPosition, float localPosition)
{
var cellSize = Context.GetCellSize();
var spacing = Context.GetStartAxisSpacing();
var groupCount = Context.GetGroupCount();
var indexInGroup = Index % groupCount;
var positionInGroup = (cellSize + spacing) * (indexInGroup - (groupCount - 1) * 0.5f);
transform.localPosition = Context.ScrollDirection == ScrollDirection.Horizontal
? new Vector2(-localPosition, -positionInGroup)
: new Vector2(positionInGroup, localPosition);
}
}
///
/// のセルを実装するための抽象基底クラス.
///
/// アイテムのデータ型.
///
public abstract class FancyGridViewCell : FancyGridViewCell
{
///
public sealed override void SetContext(FancyGridViewContext context) => base.SetContext(context);
}
}