超大量的更新 修复很多问题,gameplay特效初步
This commit is contained in:
+56
-56
@@ -12,61 +12,61 @@ using EasingCore;
|
||||
namespace FancyScrollView
|
||||
{
|
||||
/// <summary>
|
||||
/// ScrollRect スタイルのスクロールビューを実装するための抽象基底クラス.
|
||||
/// 無限スクロールおよびスナップには対応していません.
|
||||
/// <see cref="FancyScrollView{TItemData, TContext}.Context"/> が不要な場合は
|
||||
/// 代わりに <see cref="FancyScrollRect{TItemData}"/> を使用します.
|
||||
/// Documentation text normalized.
|
||||
/// Documentation text normalized.
|
||||
/// Documentation text normalized.
|
||||
/// Documentation text normalized.
|
||||
/// </summary>
|
||||
/// <typeparam name="TItemData">アイテムのデータ型.</typeparam>
|
||||
/// <typeparam name="TContext"><see cref="FancyScrollView{TItemData, TContext}.Context"/> の型.</typeparam>
|
||||
/// Documentation text normalized.
|
||||
/// Documentation text normalized.
|
||||
[RequireComponent(typeof(Scroller))]
|
||||
public abstract class FancyScrollRect<TItemData, TContext> : FancyScrollView<TItemData, TContext>
|
||||
where TContext : class, IFancyScrollRectContext, new()
|
||||
{
|
||||
/// <summary>
|
||||
/// スクロール中にセルが再利用されるまでの余白のセル数.
|
||||
/// Documentation text normalized.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <c>0</c> を指定するとセルが完全に隠れた直後に再利用されます.
|
||||
/// <c>1</c> 以上を指定すると, そのセル数だけ余分にスクロールしてから再利用されます.
|
||||
/// Documentation text normalized.
|
||||
/// Documentation text normalized.
|
||||
/// </remarks>
|
||||
[SerializeField] protected float reuseCellMarginCount = 0f;
|
||||
|
||||
/// <summary>
|
||||
/// コンテンツ先頭の余白.
|
||||
/// Documentation text normalized.
|
||||
/// </summary>
|
||||
[SerializeField] protected float paddingHead = 0f;
|
||||
|
||||
/// <summary>
|
||||
/// コンテンツ末尾の余白.
|
||||
/// Documentation text normalized.
|
||||
/// </summary>
|
||||
[SerializeField] protected float paddingTail = 0f;
|
||||
|
||||
/// <summary>
|
||||
/// スクロール軸方向のセル同士の余白.
|
||||
/// Documentation text normalized.
|
||||
/// </summary>
|
||||
[SerializeField] protected float spacing = 0f;
|
||||
|
||||
/// <summary>
|
||||
/// セルのサイズ.
|
||||
/// Documentation text normalized.
|
||||
/// </summary>
|
||||
protected abstract float CellSize { get; }
|
||||
|
||||
/// <summary>
|
||||
/// スクロール可能かどうか.
|
||||
/// Documentation text normalized.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// アイテム数が十分少なくビューポート内に全てのセルが収まっている場合は <c>false</c>, それ以外は <c>true</c> になります.
|
||||
/// Documentation text normalized.
|
||||
/// </remarks>
|
||||
protected virtual bool Scrollable => MaxScrollPosition > 0f;
|
||||
|
||||
Scroller cachedScroller;
|
||||
|
||||
/// <summary>
|
||||
/// スクロール位置を制御する <see cref="FancyScrollView.Scroller"/> のインスタンス.
|
||||
/// Documentation text normalized.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <see cref="Scroller"/> のスクロール位置を変更する際は必ず <see cref="ToScrollerPosition(float)"/> を使用して変換した位置を使用してください.
|
||||
/// Documentation text normalized.
|
||||
/// </remarks>
|
||||
protected Scroller Scroller => cachedScroller ?? (cachedScroller = GetComponent<Scroller>());
|
||||
|
||||
@@ -100,9 +100,9 @@ namespace FancyScrollView
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="Scroller"/> のスクロール位置が変更された際の処理.
|
||||
/// Documentation text normalized.
|
||||
/// </summary>
|
||||
/// <param name="p"><see cref="Scroller"/> のスクロール位置.</param>
|
||||
/// Documentation text normalized.
|
||||
void OnScrollerValueChanged(float p)
|
||||
{
|
||||
base.UpdatePosition(ToFancyScrollViewPosition(Scrollable ? p : 0f));
|
||||
@@ -121,9 +121,9 @@ namespace FancyScrollView
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// スクロール範囲を超えてスクロールされた量に基づいて, スクロールバーのサイズを縮小します.
|
||||
/// Documentation text normalized.
|
||||
/// </summary>
|
||||
/// <param name="offset">スクロール範囲を超えてスクロールされた量.</param>
|
||||
/// Documentation text normalized.
|
||||
void ShrinkScrollbar(float offset)
|
||||
{
|
||||
var scale = 1f - ToFancyScrollViewPosition(offset) / (ViewportLength - PaddingHeadLength);
|
||||
@@ -147,7 +147,7 @@ namespace FancyScrollView
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="Scroller"/> の各種状態を更新します.
|
||||
/// Documentation text normalized.
|
||||
/// </summary>
|
||||
protected void RefreshScroller()
|
||||
{
|
||||
@@ -173,53 +173,53 @@ namespace FancyScrollView
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// スクロール位置を更新します.
|
||||
/// Documentation text normalized.
|
||||
/// </summary>
|
||||
/// <param name="position">スクロール位置.</param>
|
||||
/// Documentation text normalized.
|
||||
protected new void UpdatePosition(float position)
|
||||
{
|
||||
Scroller.Position = ToScrollerPosition(position, 0.5f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 指定したアイテムの位置までジャンプします.
|
||||
/// Documentation text normalized.
|
||||
/// </summary>
|
||||
/// <param name="itemIndex">アイテムのインデックス.</param>
|
||||
/// <param name="alignment">ビューポート内におけるセル位置の基準. 0f(先頭) ~ 1f(末尾).</param>
|
||||
/// Documentation text normalized.
|
||||
/// Documentation text normalized.
|
||||
protected virtual void JumpTo(int itemIndex, float alignment = 0.5f)
|
||||
{
|
||||
Scroller.Position = ToScrollerPosition(itemIndex, alignment);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 指定したアイテムの位置まで移動します.
|
||||
/// Documentation text normalized.
|
||||
/// </summary>
|
||||
/// <param name="index">アイテムのインデックス.</param>
|
||||
/// <param name="duration">移動にかける秒数.</param>
|
||||
/// <param name="alignment">ビューポート内におけるセル位置の基準. 0f(先頭) ~ 1f(末尾).</param>
|
||||
/// <param name="onComplete">移動が完了した際に呼び出されるコールバック.</param>
|
||||
/// Documentation text normalized.
|
||||
/// Documentation text normalized.
|
||||
/// Documentation text normalized.
|
||||
/// Documentation text normalized.
|
||||
protected virtual void ScrollTo(int index, float duration, float alignment = 0.5f, Action onComplete = null)
|
||||
{
|
||||
Scroller.ScrollTo(ToScrollerPosition(index, alignment), duration, onComplete);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 指定したアイテムの位置まで移動します.
|
||||
/// Documentation text normalized.
|
||||
/// </summary>
|
||||
/// <param name="index">アイテムのインデックス.</param>
|
||||
/// <param name="duration">移動にかける秒数.</param>
|
||||
/// <param name="easing">移動に使用するイージング.</param>
|
||||
/// <param name="alignment">ビューポート内におけるセル位置の基準. 0f(先頭) ~ 1f(末尾).</param>
|
||||
/// <param name="onComplete">移動が完了した際に呼び出されるコールバック.</param>
|
||||
/// Documentation text normalized.
|
||||
/// Documentation text normalized.
|
||||
/// Documentation text normalized.
|
||||
/// Documentation text normalized.
|
||||
/// Documentation text normalized.
|
||||
protected virtual void ScrollTo(int index, float duration, Ease easing, float alignment = 0.5f, Action onComplete = null)
|
||||
{
|
||||
Scroller.ScrollTo(ToScrollerPosition(index, alignment), duration, easing, onComplete);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ビューポートとコンテンツの長さに基づいてスクロールバーのサイズを更新します.
|
||||
/// Documentation text normalized.
|
||||
/// </summary>
|
||||
/// <param name="viewportLength">ビューポートのサイズ.</param>
|
||||
/// Documentation text normalized.
|
||||
protected void UpdateScrollbarSize(float viewportLength)
|
||||
{
|
||||
var contentLength = Mathf.Max(ItemsSource.Count + (paddingHead + paddingTail - spacing) / (CellSize + spacing), 1);
|
||||
@@ -227,31 +227,31 @@ namespace FancyScrollView
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="Scroller"/> が扱うスクロール位置を <see cref="FancyScrollRect{TItemData, TContext}"/> が扱うスクロール位置に変換します.
|
||||
/// Documentation text normalized.
|
||||
/// </summary>
|
||||
/// <param name="position"><see cref="Scroller"/> が扱うスクロール位置.</param>
|
||||
/// <returns><see cref="FancyScrollRect{TItemData, TContext}"/> が扱うスクロール位置.</returns>
|
||||
/// Documentation text normalized.
|
||||
/// Documentation text normalized.
|
||||
protected float ToFancyScrollViewPosition(float position)
|
||||
{
|
||||
return position / Mathf.Max(ItemsSource.Count - 1, 1) * MaxScrollPosition - PaddingHeadLength;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="FancyScrollRect{TItemData, TContext}"/> が扱うスクロール位置を <see cref="Scroller"/> が扱うスクロール位置に変換します.
|
||||
/// Documentation text normalized.
|
||||
/// </summary>
|
||||
/// <param name="position"><see cref="FancyScrollRect{TItemData, TContext}"/> が扱うスクロール位置.</param>
|
||||
/// <returns><see cref="Scroller"/> が扱うスクロール位置.</returns>
|
||||
/// Documentation text normalized.
|
||||
/// Documentation text normalized.
|
||||
protected float ToScrollerPosition(float position)
|
||||
{
|
||||
return (position + PaddingHeadLength) / MaxScrollPosition * Mathf.Max(ItemsSource.Count - 1, 1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="FancyScrollRect{TItemData, TContext}"/> が扱うスクロール位置を <see cref="Scroller"/> が扱うスクロール位置に変換します.
|
||||
/// Documentation text normalized.
|
||||
/// </summary>
|
||||
/// <param name="position"><see cref="FancyScrollRect{TItemData, TContext}"/> が扱うスクロール位置.</param>
|
||||
/// <param name="alignment">ビューポート内におけるセル位置の基準. 0f(先頭) ~ 1f(末尾).</param>
|
||||
/// <returns><see cref="Scroller"/> が扱うスクロール位置.</returns>
|
||||
/// Documentation text normalized.
|
||||
/// Documentation text normalized.
|
||||
/// Documentation text normalized.
|
||||
protected float ToScrollerPosition(float position, float alignment = 0.5f)
|
||||
{
|
||||
var offset = alignment * (ScrollLength - (1f + reuseCellMarginCount * 2f))
|
||||
@@ -260,9 +260,9 @@ namespace FancyScrollView
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 指定された設定を実現するための
|
||||
/// <see cref="FancyScrollView{TItemData,TContext}.cellInterval"/> と
|
||||
/// <see cref="FancyScrollView{TItemData,TContext}.scrollOffset"/> を計算して適用します.
|
||||
/// Documentation text normalized.
|
||||
/// Documentation text normalized.
|
||||
/// Documentation text normalized.
|
||||
/// </summary>
|
||||
protected void AdjustCellIntervalAndScrollOffset()
|
||||
{
|
||||
@@ -296,10 +296,10 @@ namespace FancyScrollView
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ScrollRect スタイルのスクロールビューを実装するための抽象基底クラス.
|
||||
/// 無限スクロールおよびスナップには対応していません.
|
||||
/// Documentation text normalized.
|
||||
/// Documentation text normalized.
|
||||
/// </summary>
|
||||
/// <typeparam name="TItemData">アイテムのデータ型.</typeparam>
|
||||
/// Documentation text normalized.
|
||||
/// <seealso cref="FancyScrollRect{TItemData, TContext}"/>
|
||||
public abstract class FancyScrollRect<TItemData> : FancyScrollRect<TItemData, FancyScrollRectContext> { }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user