diff --git a/Editor/FancyScrollView.meta b/Editor/FancyScrollView.meta
deleted file mode 100644
index 28ed9d7..0000000
--- a/Editor/FancyScrollView.meta
+++ /dev/null
@@ -1,8 +0,0 @@
-fileFormatVersion: 2
-guid: 77a80d348c62e93459753f8e704f474d
-folderAsset: yes
-DefaultImporter:
- externalObjects: {}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Editor/FancyScrollView/ScrollerEditor.cs b/Editor/FancyScrollView/ScrollerEditor.cs
deleted file mode 100644
index 34673e3..0000000
--- a/Editor/FancyScrollView/ScrollerEditor.cs
+++ /dev/null
@@ -1,119 +0,0 @@
-/// Credit setchi (https://github.com/setchi)
-/// Sourced from - https://github.com/setchi/FancyScrollView
-
-using UnityEditor;
-using UnityEditor.AnimatedValues;
-
-namespace UnityEngine.UI.Extensions
-{
- [CustomEditor(typeof(Scroller))]
- [CanEditMultipleObjects]
- public class ScrollerEditor : Editor
- {
- SerializedProperty viewport;
- SerializedProperty scrollDirection;
- SerializedProperty movementType;
- SerializedProperty elasticity;
- SerializedProperty scrollSensitivity;
- SerializedProperty inertia;
- SerializedProperty decelerationRate;
- SerializedProperty snap;
- SerializedProperty draggable;
- SerializedProperty scrollbar;
-
- AnimBool showElasticity;
- AnimBool showInertiaRelatedValues;
-
- void OnEnable()
- {
- viewport = serializedObject.FindProperty("viewport");
- scrollDirection = serializedObject.FindProperty("scrollDirection");
- movementType = serializedObject.FindProperty("movementType");
- elasticity = serializedObject.FindProperty("elasticity");
- scrollSensitivity = serializedObject.FindProperty("scrollSensitivity");
- inertia = serializedObject.FindProperty("inertia");
- decelerationRate = serializedObject.FindProperty("decelerationRate");
- snap = serializedObject.FindProperty("snap");
- draggable = serializedObject.FindProperty("draggable");
- scrollbar = serializedObject.FindProperty("scrollbar");
-
- showElasticity = new AnimBool(Repaint);
- showInertiaRelatedValues = new AnimBool(Repaint);
- SetAnimBools(true);
- }
-
- void OnDisable()
- {
- showElasticity.valueChanged.RemoveListener(Repaint);
- showInertiaRelatedValues.valueChanged.RemoveListener(Repaint);
- }
-
- void SetAnimBools(bool instant)
- {
- SetAnimBool(showElasticity, !movementType.hasMultipleDifferentValues && movementType.enumValueIndex == (int)MovementType.Elastic, instant);
- SetAnimBool(showInertiaRelatedValues, !inertia.hasMultipleDifferentValues && inertia.boolValue, instant);
- }
-
- void SetAnimBool(AnimBool a, bool value, bool instant)
- {
- if (instant)
- {
- a.value = value;
- }
- else
- {
- a.target = value;
- }
- }
-
- public override void OnInspectorGUI()
- {
- SetAnimBools(false);
-
- serializedObject.Update();
- EditorGUILayout.PropertyField(viewport);
- EditorGUILayout.PropertyField(scrollDirection);
- EditorGUILayout.PropertyField(movementType);
- DrawMovementTypeRelatedValue();
- EditorGUILayout.PropertyField(scrollSensitivity);
- EditorGUILayout.PropertyField(inertia);
- DrawInertiaRelatedValues();
- EditorGUILayout.PropertyField(draggable);
- EditorGUILayout.PropertyField(scrollbar);
- serializedObject.ApplyModifiedProperties();
- }
-
- void DrawMovementTypeRelatedValue()
- {
- using (var group = new EditorGUILayout.FadeGroupScope(showElasticity.faded))
- {
- if (!group.visible)
- {
- return;
- }
-
- using (new EditorGUI.IndentLevelScope())
- {
- EditorGUILayout.PropertyField(elasticity);
- }
- }
- }
-
- void DrawInertiaRelatedValues()
- {
- using (var group = new EditorGUILayout.FadeGroupScope(showInertiaRelatedValues.faded))
- {
- if (!group.visible)
- {
- return;
- }
-
- using (new EditorGUI.IndentLevelScope())
- {
- EditorGUILayout.PropertyField(decelerationRate);
- EditorGUILayout.PropertyField(snap);
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/Editor/FancyScrollView/ScrollerEditor.cs.meta b/Editor/FancyScrollView/ScrollerEditor.cs.meta
deleted file mode 100644
index 936aad4..0000000
--- a/Editor/FancyScrollView/ScrollerEditor.cs.meta
+++ /dev/null
@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: e82bfdd42ec254849830933cbaf350fa
-MonoImporter:
- externalObjects: {}
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Runtime/Scripts/Layout/FancyScrollView.meta b/Runtime/Scripts/Layout/FancyScrollView.meta
deleted file mode 100644
index d65ed5a..0000000
--- a/Runtime/Scripts/Layout/FancyScrollView.meta
+++ /dev/null
@@ -1,8 +0,0 @@
-fileFormatVersion: 2
-guid: d1ddf7c4a2094c8429c834b8c71bb812
-folderAsset: yes
-DefaultImporter:
- externalObjects: {}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Runtime/Scripts/Layout/FancyScrollView/Core.meta b/Runtime/Scripts/Layout/FancyScrollView/Core.meta
deleted file mode 100644
index c5d2095..0000000
--- a/Runtime/Scripts/Layout/FancyScrollView/Core.meta
+++ /dev/null
@@ -1,8 +0,0 @@
-fileFormatVersion: 2
-guid: 6096cd9225d267f4da3b54947c75809c
-folderAsset: yes
-DefaultImporter:
- externalObjects: {}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Runtime/Scripts/Layout/FancyScrollView/Core/FancyCell.cs b/Runtime/Scripts/Layout/FancyScrollView/Core/FancyCell.cs
deleted file mode 100644
index f32e26b..0000000
--- a/Runtime/Scripts/Layout/FancyScrollView/Core/FancyCell.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-/// Credit setchi (https://github.com/setchi)
-/// Sourced from - https://github.com/setchi/FancyScrollView
-
-namespace UnityEngine.UI.Extensions
-{
- ///
- /// のセルを実装するための抽象基底クラス.
- /// が不要な場合は
- /// 代わりに を使用します.
- ///
- /// アイテムのデータ型.
- /// の型.
- public abstract class FancyCell : MonoBehaviour where TContext : class, new()
- {
- ///
- /// このセルで表示しているデータのインデックス.
- ///
- public int Index { get; set; } = -1;
-
- ///
- /// このセルの可視状態.
- ///
- public virtual bool IsVisible => gameObject.activeSelf;
-
- ///
- /// の参照.
- /// セルとスクロールビュー間で同じインスタンスが共有されます. 情報の受け渡しや状態の保持に使用します.
- ///
- protected TContext Context { get; private set; }
-
- ///
- /// をセットします.
- ///
- /// コンテキスト.
- public virtual void SetContext(TContext context) => Context = context;
-
- ///
- /// 初期化を行います.
- ///
- public virtual void Initialize() { }
-
- ///
- /// このセルの可視状態を設定します.
- ///
- /// 可視状態なら true, 非可視状態なら false.
- public virtual void SetVisible(bool visible) => gameObject.SetActive(visible);
-
- ///
- /// アイテムデータに基づいてこのセルの表示内容を更新します.
- ///
- /// アイテムデータ.
- public abstract void UpdateContent(TItemData itemData);
-
- ///
- /// 0.0f ~ 1.0f の値に基づいてこのセルのスクロール位置を更新します.
- ///
- /// ビューポート範囲の正規化されたスクロール位置.
- public abstract void UpdatePosition(float position);
- }
-
- ///
- /// のセルを実装するための抽象基底クラス.
- ///
- /// アイテムのデータ型.
- ///
- public abstract class FancyCell : FancyCell
- {
- ///
- public sealed override void SetContext(NullContext context) => base.SetContext(context);
- }
-}
\ No newline at end of file
diff --git a/Runtime/Scripts/Layout/FancyScrollView/Core/FancyCell.cs.meta b/Runtime/Scripts/Layout/FancyScrollView/Core/FancyCell.cs.meta
deleted file mode 100644
index e71ac73..0000000
--- a/Runtime/Scripts/Layout/FancyScrollView/Core/FancyCell.cs.meta
+++ /dev/null
@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 6610dee308450ec40899aeedfd85e972
-MonoImporter:
- externalObjects: {}
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Runtime/Scripts/Layout/FancyScrollView/Core/FancyScrollView.cs b/Runtime/Scripts/Layout/FancyScrollView/Core/FancyScrollView.cs
deleted file mode 100644
index df3f942..0000000
--- a/Runtime/Scripts/Layout/FancyScrollView/Core/FancyScrollView.cs
+++ /dev/null
@@ -1,216 +0,0 @@
-/// Credit setchi (https://github.com/setchi)
-/// Sourced from - https://github.com/setchi/FancyScrollView
-
-using System.Collections.Generic;
-
-namespace UnityEngine.UI.Extensions
-{
- ///
- /// スクロールビューを実装するための抽象基底クラス.
- /// 無限スクロールおよびスナップに対応しています.
- /// が不要な場合は
- /// 代わりに を使用します.
- ///
- /// アイテムのデータ型.
- /// の型.
- public abstract class FancyScrollView : MonoBehaviour where TContext : class, new()
- {
- ///
- /// セル同士の間隔.
- ///
- [SerializeField, Range(1e-2f, 1f)] protected float cellInterval = 0.2f;
-
- ///
- /// スクロール位置の基準.
- ///
- ///
- /// たとえば、 0.5 を指定してスクロール位置が 0 の場合, 中央に最初のセルが配置されます.
- ///
- [SerializeField, Range(0f, 1f)] protected float scrollOffset = 0.5f;
-
- ///
- /// セルを循環して配置させるどうか.
- ///
- ///
- /// true にすると最後のセルの後に最初のセル, 最初のセルの前に最後のセルが並ぶようになります.
- /// 無限スクロールを実装する場合は true を指定します.
- ///
- [SerializeField] protected bool loop = false;
-
- ///
- /// セルの親要素となる Transform.
- ///
- [SerializeField] protected Transform cellContainer = default;
-
- readonly IList> pool = new List>();
-
- ///
- /// 初期化済みかどうか.
- ///
- protected bool initialized;
-
- ///
- /// 現在のスクロール位置.
- ///
- protected float currentPosition;
-
- ///
- /// セルの Prefab.
- ///
- protected abstract GameObject CellPrefab { get; }
-
- ///
- /// アイテム一覧のデータ.
- ///
- protected IList ItemsSource { get; set; } = new List();
-
- ///
- /// のインスタンス.
- /// セルとスクロールビュー間で同じインスタンスが共有されます. 情報の受け渡しや状態の保持に使用します.
- ///
- protected TContext Context { get; } = new TContext();
-
- ///
- /// 初期化を行います.
- ///
- ///
- /// 最初にセルが生成される直前に呼び出されます.
- ///
- protected virtual void Initialize() { }
-
- ///
- /// 渡されたアイテム一覧に基づいて表示内容を更新します.
- ///
- /// アイテム一覧.
- protected virtual void UpdateContents(IList itemsSource)
- {
- ItemsSource = itemsSource;
- Refresh();
- }
-
- ///
- /// セルのレイアウトを強制的に更新します.
- ///
- protected virtual void Relayout() => UpdatePosition(currentPosition, false);
-
- ///
- /// セルのレイアウトと表示内容を強制的に更新します.
- ///
- protected virtual void Refresh() => UpdatePosition(currentPosition, true);
-
- ///
- /// スクロール位置を更新します.
- ///
- /// スクロール位置.
- protected virtual void UpdatePosition(float position) => UpdatePosition(position, false);
-
- void UpdatePosition(float position, bool forceRefresh)
- {
- if (!initialized)
- {
- Initialize();
- initialized = true;
- }
-
- currentPosition = position;
-
- var p = position - scrollOffset / cellInterval;
- var firstIndex = Mathf.CeilToInt(p);
- var firstPosition = (Mathf.Ceil(p) - p) * cellInterval;
-
- if (firstPosition + pool.Count * cellInterval < 1f)
- {
- ResizePool(firstPosition);
- }
-
- UpdateCells(firstPosition, firstIndex, forceRefresh);
- }
-
- void ResizePool(float firstPosition)
- {
- Debug.Assert(CellPrefab != null);
- Debug.Assert(cellContainer != null);
-
- var addCount = Mathf.CeilToInt((1f - firstPosition) / cellInterval) - pool.Count;
- for (var i = 0; i < addCount; i++)
- {
- var cell = Instantiate(CellPrefab, cellContainer).GetComponent>();
- if (cell == null)
- {
- throw new MissingComponentException(string.Format(
- "FancyCell<{0}, {1}> component not found in {2}.",
- typeof(TItemData).FullName, typeof(TContext).FullName, CellPrefab.name));
- }
-
- cell.SetContext(Context);
- cell.Initialize();
- cell.SetVisible(false);
- pool.Add(cell);
- }
- }
-
- void UpdateCells(float firstPosition, int firstIndex, bool forceRefresh)
- {
- for (var i = 0; i < pool.Count; i++)
- {
- var index = firstIndex + i;
- var position = firstPosition + i * cellInterval;
- var cell = pool[CircularIndex(index, pool.Count)];
-
- if (loop)
- {
- index = CircularIndex(index, ItemsSource.Count);
- }
-
- if (index < 0 || index >= ItemsSource.Count || position > 1f)
- {
- cell.SetVisible(false);
- continue;
- }
-
- if (forceRefresh || cell.Index != index || !cell.IsVisible)
- {
- cell.Index = index;
- cell.SetVisible(true);
- cell.UpdateContent(ItemsSource[index]);
- }
-
- cell.UpdatePosition(position);
- }
- }
-
- int CircularIndex(int i, int size) => size < 1 ? 0 : i < 0 ? size - 1 + (i + 1) % size : i % size;
-
-#if UNITY_EDITOR
- bool cachedLoop;
- float cachedCellInterval, cachedScrollOffset;
-
- void LateUpdate()
- {
- if (cachedLoop != loop ||
- cachedCellInterval != cellInterval ||
- cachedScrollOffset != scrollOffset)
- {
- cachedLoop = loop;
- cachedCellInterval = cellInterval;
- cachedScrollOffset = scrollOffset;
-
- UpdatePosition(currentPosition);
- }
- }
-#endif
- }
-
- ///
- /// のコンテキストクラス.
- ///
- public sealed class NullContext { }
-
- ///
- /// スクロールビューを実装するための抽象基底クラス.
- /// 無限スクロールおよびスナップに対応しています.
- ///
- ///
- ///
- public abstract class FancyScrollView : FancyScrollView { }
-}
\ No newline at end of file
diff --git a/Runtime/Scripts/Layout/FancyScrollView/Core/FancyScrollView.cs.meta b/Runtime/Scripts/Layout/FancyScrollView/Core/FancyScrollView.cs.meta
deleted file mode 100644
index b969106..0000000
--- a/Runtime/Scripts/Layout/FancyScrollView/Core/FancyScrollView.cs.meta
+++ /dev/null
@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 0e38f4de7b1b5a5429228884014d12ec
-MonoImporter:
- externalObjects: {}
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Runtime/Scripts/Layout/FancyScrollView/GridView.meta b/Runtime/Scripts/Layout/FancyScrollView/GridView.meta
deleted file mode 100644
index f61d146..0000000
--- a/Runtime/Scripts/Layout/FancyScrollView/GridView.meta
+++ /dev/null
@@ -1,8 +0,0 @@
-fileFormatVersion: 2
-guid: c7768f2982b0142ab876d2bb4b597646
-folderAsset: yes
-DefaultImporter:
- externalObjects: {}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Runtime/Scripts/Layout/FancyScrollView/GridView/FancyCellGroup.cs b/Runtime/Scripts/Layout/FancyScrollView/GridView/FancyCellGroup.cs
deleted file mode 100644
index 5aa3698..0000000
--- a/Runtime/Scripts/Layout/FancyScrollView/GridView/FancyCellGroup.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-/// Credit setchi (https://github.com/setchi)
-/// Sourced from - https://github.com/setchi/FancyScrollView
-
-using System.Linq;
-
-namespace UnityEngine.UI.Extensions
-{
- ///
- /// 複数の を持つセルグループ実装するための抽象基底クラス.
- ///
- /// アイテムのデータ型.
- /// の型.
- public abstract class FancyCellGroup : FancyCell
- where TContext : class, IFancyCellGroupContext, new()
- {
- ///
- /// このグループで表示するセルの配列.
- ///
- protected virtual FancyCell[] Cells { get; private set; }
-
- ///
- /// このグループで表示するセルの配列をインスタンス化します.
- ///
- /// このグループで表示するセルの配列.
- protected virtual FancyCell[] InstantiateCells()
- {
- return Enumerable.Range(0, Context.GetGroupCount())
- .Select(_ => Instantiate(Context.CellTemplate, transform))
- .Select(x => x.GetComponent>())
- .ToArray();
- }
-
- ///
- public override void Initialize()
- {
- Cells = InstantiateCells();
- Debug.Assert(Cells.Length == Context.GetGroupCount());
-
- for (var i = 0; i < Cells.Length; i++)
- {
- Cells[i].SetContext(Context);
- Cells[i].Initialize();
- }
- }
-
- ///
- public override void UpdateContent(TItemData[] contents)
- {
- var firstCellIndex = Index * Context.GetGroupCount();
-
- for (var i = 0; i < Cells.Length; i++)
- {
- Cells[i].Index = i + firstCellIndex;
- Cells[i].SetVisible(i < contents.Length);
-
- if (Cells[i].IsVisible)
- {
- Cells[i].UpdateContent(contents[i]);
- }
- }
- }
-
- ///
- public override void UpdatePosition(float position)
- {
- for (var i = 0; i < Cells.Length; i++)
- {
- Cells[i].UpdatePosition(position);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/Runtime/Scripts/Layout/FancyScrollView/GridView/FancyCellGroup.cs.meta b/Runtime/Scripts/Layout/FancyScrollView/GridView/FancyCellGroup.cs.meta
deleted file mode 100644
index 65a825d..0000000
--- a/Runtime/Scripts/Layout/FancyScrollView/GridView/FancyCellGroup.cs.meta
+++ /dev/null
@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 5d97e25c7748b8d44acd2298e509c8f1
-MonoImporter:
- externalObjects: {}
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Runtime/Scripts/Layout/FancyScrollView/GridView/FancyGridView.cs b/Runtime/Scripts/Layout/FancyScrollView/GridView/FancyGridView.cs
deleted file mode 100644
index 4e1417b..0000000
--- a/Runtime/Scripts/Layout/FancyScrollView/GridView/FancyGridView.cs
+++ /dev/null
@@ -1,181 +0,0 @@
-/// Credit setchi (https://github.com/setchi)
-/// Sourced from - https://github.com/setchi/FancyScrollView
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using UnityEngine.UI.Extensions.EasingCore;
-
-namespace UnityEngine.UI.Extensions
-{
- ///
- /// グリッドレイアウトのスクロールビューを実装するための抽象基底クラス.
- /// 無限スクロールおよびスナップには対応していません.
- /// が不要な場合は
- /// 代わりに を使用します.
- ///
- /// アイテムのデータ型.
- /// の型.
- public abstract class FancyGridView : FancyScrollRect
- where TContext : class, IFancyGridViewContext, new()
- {
- ///
- /// デフォルトのセルグループクラス.
- ///
- protected abstract class DefaultCellGroup : FancyCellGroup { }
-
- ///
- /// 最初にセルを配置する軸方向のセル同士の余白.
- ///
- [SerializeField] protected float startAxisSpacing = 0f;
-
- ///
- /// 最初にセルを配置する軸方向のセル数.
- ///
- [SerializeField] protected int startAxisCellCount = 4;
-
- ///
- /// セルのサイズ.
- ///
- [SerializeField] protected Vector2 cellSize = new Vector2(100f, 100f);
-
- ///
- /// セルのグループ Prefab.
- ///
- ///
- /// では,
- /// を最初にセルを配置する軸方向のセルコンテナとして使用します.
- ///
- protected sealed override GameObject CellPrefab => cellGroupTemplate;
-
- ///
- protected override float CellSize => Scroller.ScrollDirection == ScrollDirection.Horizontal
- ? cellSize.x
- : cellSize.y;
-
- ///
- /// アイテムの総数.
- ///
- public int DataCount { get; private set; }
-
- GameObject cellGroupTemplate;
-
- ///
- protected override void Initialize()
- {
- base.Initialize();
-
- Debug.Assert(startAxisCellCount > 0);
-
- Context.ScrollDirection = Scroller.ScrollDirection;
- Context.GetGroupCount = () => startAxisCellCount;
- Context.GetStartAxisSpacing = () => startAxisSpacing;
- Context.GetCellSize = () => Scroller.ScrollDirection == ScrollDirection.Horizontal
- ? cellSize.y
- : cellSize.x;
-
- SetupCellTemplate();
- }
-
- ///
- /// 最初にセルが生成される直前に呼び出されます.
- /// メソッドを使用してセルテンプレートのセットアップを行ってください.
- ///
- ///
- ///
- /// {
- /// class CellGroup : DefaultCellGroup { }
- ///
- /// [SerializeField] Cell cellPrefab = default;
- ///
- /// protected override void SetupCellTemplate() => Setup(cellPrefab);
- /// }
- /// ]]>
- ///
- protected abstract void SetupCellTemplate();
-
- ///
- /// セルテンプレートのセットアップを行います.
- ///
- /// セルのテンプレート.
- /// セルグループの型.
- protected virtual void Setup(FancyCell cellTemplate)
- where TGroup : FancyCell
- {
- Context.CellTemplate = cellTemplate.gameObject;
-
- cellGroupTemplate = new GameObject("Group").AddComponent().gameObject;
- cellGroupTemplate.transform.SetParent(cellContainer, false);
- cellGroupTemplate.SetActive(false);
- }
-
- ///
- /// 渡されたアイテム一覧に基づいて表示内容を更新します.
- ///
- /// アイテム一覧.
- public virtual void UpdateContents(IList items)
- {
- DataCount = items.Count;
-
- var itemGroups = items
- .Select((item, index) => (item, index))
- .GroupBy(
- x => x.index / startAxisCellCount,
- x => x.item)
- .Select(group => group.ToArray())
- .ToArray();
-
- UpdateContents(itemGroups);
- }
-
- ///
- /// 指定したアイテムの位置までジャンプします.
- ///
- /// アイテムのインデックス.
- /// ビューポート内におけるセル位置の基準. 0f(先頭) ~ 1f(末尾).
- protected override void JumpTo(int itemIndex, float alignment = 0.5f)
- {
- var groupIndex = itemIndex / startAxisCellCount;
- base.JumpTo(groupIndex, alignment);
- }
-
- ///
- /// 指定したアイテムの位置まで移動します.
- ///
- /// アイテムのインデックス.
- /// 移動にかける秒数.
- /// ビューポート内におけるセル位置の基準. 0f(先頭) ~ 1f(末尾).
- /// 移動が完了した際に呼び出されるコールバック.
- protected override void ScrollTo(int itemIndex, float duration, float alignment = 0.5f, Action onComplete = null)
- {
- var groupIndex = itemIndex / startAxisCellCount;
- base.ScrollTo(groupIndex, duration, alignment, onComplete);
- }
-
- ///
- /// 指定したアイテムの位置まで移動します.
- ///
- /// アイテムのインデックス.
- /// 移動にかける秒数.
- /// 移動に使用するイージング.
- /// ビューポート内におけるセル位置の基準. 0f(先頭) ~ 1f(末尾).
- /// 移動が完了した際に呼び出されるコールバック.
- protected override void ScrollTo(int itemIndex, float duration, Ease easing, float alignment = 0.5f, Action onComplete = null)
- {
- var groupIndex = itemIndex / startAxisCellCount;
- base.ScrollTo(groupIndex, duration, easing, alignment, onComplete);
- }
- }
-
- ///
- /// グリッドレイアウトのスクロールビューを実装するための抽象基底クラス.
- /// 無限スクロールおよびスナップには対応していません.
- ///
- /// アイテムのデータ型.
- ///
- public abstract class FancyGridView : FancyGridView { }
-}
\ No newline at end of file
diff --git a/Runtime/Scripts/Layout/FancyScrollView/GridView/FancyGridView.cs.meta b/Runtime/Scripts/Layout/FancyScrollView/GridView/FancyGridView.cs.meta
deleted file mode 100644
index e1254c5..0000000
--- a/Runtime/Scripts/Layout/FancyScrollView/GridView/FancyGridView.cs.meta
+++ /dev/null
@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: e806c8d18b1ff45bb87e9a5b87ec85e3
-MonoImporter:
- externalObjects: {}
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Runtime/Scripts/Layout/FancyScrollView/GridView/FancyGridViewCell.cs b/Runtime/Scripts/Layout/FancyScrollView/GridView/FancyGridViewCell.cs
deleted file mode 100644
index 0e78f0f..0000000
--- a/Runtime/Scripts/Layout/FancyScrollView/GridView/FancyGridViewCell.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-/// 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);
- }
-}
\ No newline at end of file
diff --git a/Runtime/Scripts/Layout/FancyScrollView/GridView/FancyGridViewCell.cs.meta b/Runtime/Scripts/Layout/FancyScrollView/GridView/FancyGridViewCell.cs.meta
deleted file mode 100644
index 8320c0a..0000000
--- a/Runtime/Scripts/Layout/FancyScrollView/GridView/FancyGridViewCell.cs.meta
+++ /dev/null
@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: ab8a59bbf5118824ab084e32342ad86b
-MonoImporter:
- externalObjects: {}
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Runtime/Scripts/Layout/FancyScrollView/GridView/FancyGridViewContext.cs b/Runtime/Scripts/Layout/FancyScrollView/GridView/FancyGridViewContext.cs
deleted file mode 100644
index eb5de46..0000000
--- a/Runtime/Scripts/Layout/FancyScrollView/GridView/FancyGridViewContext.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-/// Credit setchi (https://github.com/setchi)
-/// Sourced from - https://github.com/setchi/FancyScrollView
-
-using System;
-
-namespace UnityEngine.UI.Extensions
-{
- ///
- /// のコンテキスト基底クラス.
- ///
- public class FancyGridViewContext : IFancyGridViewContext
- {
- ScrollDirection IFancyScrollRectContext.ScrollDirection { get; set; }
- Func<(float ScrollSize, float ReuseMargin)> IFancyScrollRectContext.CalculateScrollSize { get; set; }
- GameObject IFancyCellGroupContext.CellTemplate { get; set; }
- Func IFancyCellGroupContext.GetGroupCount { get; set; }
- Func IFancyGridViewContext.GetStartAxisSpacing { get; set; }
- Func IFancyGridViewContext.GetCellSize { get; set; }
- }
-}
\ No newline at end of file
diff --git a/Runtime/Scripts/Layout/FancyScrollView/GridView/FancyGridViewContext.cs.meta b/Runtime/Scripts/Layout/FancyScrollView/GridView/FancyGridViewContext.cs.meta
deleted file mode 100644
index 49a8040..0000000
--- a/Runtime/Scripts/Layout/FancyScrollView/GridView/FancyGridViewContext.cs.meta
+++ /dev/null
@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 954a17398bfb54ee7baac3d7ab7e822c
-MonoImporter:
- externalObjects: {}
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Runtime/Scripts/Layout/FancyScrollView/GridView/IFancyCellGroupContext.cs b/Runtime/Scripts/Layout/FancyScrollView/GridView/IFancyCellGroupContext.cs
deleted file mode 100644
index 07854ce..0000000
--- a/Runtime/Scripts/Layout/FancyScrollView/GridView/IFancyCellGroupContext.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-/// Credit setchi (https://github.com/setchi)
-/// Sourced from - https://github.com/setchi/FancyScrollView
-
-using System;
-
-namespace UnityEngine.UI.Extensions
-{
- ///
- /// のコンテキストインターフェース.
- ///
- public interface IFancyCellGroupContext
- {
- GameObject CellTemplate { get; set; }
- Func GetGroupCount { get; set; }
- }
-}
\ No newline at end of file
diff --git a/Runtime/Scripts/Layout/FancyScrollView/GridView/IFancyCellGroupContext.cs.meta b/Runtime/Scripts/Layout/FancyScrollView/GridView/IFancyCellGroupContext.cs.meta
deleted file mode 100644
index 1733d84..0000000
--- a/Runtime/Scripts/Layout/FancyScrollView/GridView/IFancyCellGroupContext.cs.meta
+++ /dev/null
@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 1dc086f250206754aa8449e252d50388
-MonoImporter:
- externalObjects: {}
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Runtime/Scripts/Layout/FancyScrollView/GridView/IFancyGridViewContext.cs b/Runtime/Scripts/Layout/FancyScrollView/GridView/IFancyGridViewContext.cs
deleted file mode 100644
index 33adb1b..0000000
--- a/Runtime/Scripts/Layout/FancyScrollView/GridView/IFancyGridViewContext.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-/// Credit setchi (https://github.com/setchi)
-/// Sourced from - https://github.com/setchi/FancyScrollView
-
-using System;
-
-namespace UnityEngine.UI.Extensions
-{
- ///
- /// のコンテキストインターフェース.
- ///
- public interface IFancyGridViewContext : IFancyScrollRectContext, IFancyCellGroupContext
- {
- Func GetStartAxisSpacing { get; set; }
- Func GetCellSize { get; set ; }
- }
-}
\ No newline at end of file
diff --git a/Runtime/Scripts/Layout/FancyScrollView/GridView/IFancyGridViewContext.cs.meta b/Runtime/Scripts/Layout/FancyScrollView/GridView/IFancyGridViewContext.cs.meta
deleted file mode 100644
index 1bed129..0000000
--- a/Runtime/Scripts/Layout/FancyScrollView/GridView/IFancyGridViewContext.cs.meta
+++ /dev/null
@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 3cf2d53d9c81945c28f7c558a7c40ba3
-MonoImporter:
- externalObjects: {}
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Runtime/Scripts/Layout/FancyScrollView/ScrollRect.meta b/Runtime/Scripts/Layout/FancyScrollView/ScrollRect.meta
deleted file mode 100644
index f409f53..0000000
--- a/Runtime/Scripts/Layout/FancyScrollView/ScrollRect.meta
+++ /dev/null
@@ -1,8 +0,0 @@
-fileFormatVersion: 2
-guid: e2c5beedd885c4490a86bb4973f965bf
-folderAsset: yes
-DefaultImporter:
- externalObjects: {}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Runtime/Scripts/Layout/FancyScrollView/ScrollRect/FancyScrollRect.cs b/Runtime/Scripts/Layout/FancyScrollView/ScrollRect/FancyScrollRect.cs
deleted file mode 100644
index 732abe0..0000000
--- a/Runtime/Scripts/Layout/FancyScrollView/ScrollRect/FancyScrollRect.cs
+++ /dev/null
@@ -1,301 +0,0 @@
-/// Credit setchi (https://github.com/setchi)
-/// Sourced from - https://github.com/setchi/FancyScrollView
-
-using System;
-using System.Collections.Generic;
-using UnityEngine.UI.Extensions.EasingCore;
-
-namespace UnityEngine.UI.Extensions
-{
- ///
- /// ScrollRect スタイルのスクロールビューを実装するための抽象基底クラス.
- /// 無限スクロールおよびスナップには対応していません.
- /// が不要な場合は
- /// 代わりに を使用します.
- ///
- /// アイテムのデータ型.
- /// の型.
- [RequireComponent(typeof(Scroller))]
- public abstract class FancyScrollRect : FancyScrollView
- where TContext : class, IFancyScrollRectContext, new()
- {
- ///
- /// スクロール中にセルが再利用されるまでの余白のセル数.
- ///
- ///
- /// 0 を指定するとセルが完全に隠れた直後に再利用されます.
- /// 1 以上を指定すると, そのセル数だけ余分にスクロールしてから再利用されます.
- ///
- [SerializeField] protected float reuseCellMarginCount = 0f;
-
- ///
- /// コンテンツ先頭の余白.
- ///
- [SerializeField] protected float paddingHead = 0f;
-
- ///
- /// コンテンツ末尾の余白.
- ///
- [SerializeField] protected float paddingTail = 0f;
-
- ///
- /// スクロール軸方向のセル同士の余白.
- ///
- [SerializeField] protected float spacing = 0f;
-
- ///
- /// セルのサイズ.
- ///
- protected abstract float CellSize { get; }
-
- ///
- /// スクロール可能かどうか.
- ///
- ///
- /// アイテム数が十分少なくビューポート内に全てのセルが収まっている場合は false, それ以外は true になります.
- ///
- protected virtual bool Scrollable => MaxScrollPosition > 0f;
-
- Scroller cachedScroller;
-
- ///
- /// スクロール位置を制御する のインスタンス.
- ///
- ///
- /// のスクロール位置を変更する際は必ず を使用して変換した位置を使用してください.
- ///
- protected Scroller Scroller => cachedScroller ?? (cachedScroller = GetComponent());
-
- float ScrollLength => 1f / Mathf.Max(cellInterval, 1e-2f) - 1f;
-
- float ViewportLength => ScrollLength - reuseCellMarginCount * 2f;
-
- float PaddingHeadLength => (paddingHead - spacing * 0.5f) / (CellSize + spacing);
-
- float MaxScrollPosition => ItemsSource.Count
- - ScrollLength
- + reuseCellMarginCount * 2f
- + (paddingHead + paddingTail - spacing) / (CellSize + spacing);
-
- ///
- protected override void Initialize()
- {
- base.Initialize();
-
- Context.ScrollDirection = Scroller.ScrollDirection;
- Context.CalculateScrollSize = () =>
- {
- var interval = CellSize + spacing;
- var reuseMargin = interval * reuseCellMarginCount;
- var scrollSize = Scroller.ViewportSize + interval + reuseMargin * 2f;
- return (scrollSize, reuseMargin);
- };
-
- AdjustCellIntervalAndScrollOffset();
- Scroller.OnValueChanged(OnScrollerValueChanged);
- }
-
- ///
- /// のスクロール位置が変更された際の処理.
- ///
- /// のスクロール位置.
- void OnScrollerValueChanged(float p)
- {
- base.UpdatePosition(ToFancyScrollViewPosition(Scrollable ? p : 0f));
-
- if (Scroller.Scrollbar)
- {
- if (p > ItemsSource.Count - 1)
- {
- ShrinkScrollbar(p - (ItemsSource.Count - 1));
- }
- else if (p < 0f)
- {
- ShrinkScrollbar(-p);
- }
- }
- }
-
- ///
- /// スクロール範囲を超えてスクロールされた量に基づいて, スクロールバーのサイズを縮小します.
- ///
- /// スクロール範囲を超えてスクロールされた量.
- void ShrinkScrollbar(float offset)
- {
- var scale = 1f - ToFancyScrollViewPosition(offset) / (ViewportLength - PaddingHeadLength);
- UpdateScrollbarSize((ViewportLength - PaddingHeadLength) * scale);
- }
-
- ///
- protected override void Refresh()
- {
- AdjustCellIntervalAndScrollOffset();
- RefreshScroller();
- base.Refresh();
- }
-
- ///
- protected override void Relayout()
- {
- AdjustCellIntervalAndScrollOffset();
- RefreshScroller();
- base.Relayout();
- }
-
- ///
- /// の各種状態を更新します.
- ///
- protected void RefreshScroller()
- {
- Scroller.Draggable = Scrollable;
- Scroller.ScrollSensitivity = ToScrollerPosition(ViewportLength - PaddingHeadLength);
- Scroller.Position = ToScrollerPosition(currentPosition);
-
- if (Scroller.Scrollbar)
- {
- Scroller.Scrollbar.gameObject.SetActive(Scrollable);
- UpdateScrollbarSize(ViewportLength);
- }
- }
-
- ///
- protected override void UpdateContents(IList items)
- {
- AdjustCellIntervalAndScrollOffset();
- base.UpdateContents(items);
-
- Scroller.SetTotalCount(items.Count);
- RefreshScroller();
- }
-
- ///
- /// スクロール位置を更新します.
- ///
- /// スクロール位置.
- protected new void UpdatePosition(float position)
- {
- Scroller.Position = ToScrollerPosition(position, 0.5f);
- }
-
- ///
- /// 指定したアイテムの位置までジャンプします.
- ///
- /// アイテムのインデックス.
- /// ビューポート内におけるセル位置の基準. 0f(先頭) ~ 1f(末尾).
- protected virtual void JumpTo(int itemIndex, float alignment = 0.5f)
- {
- Scroller.Position = ToScrollerPosition(itemIndex, alignment);
- }
-
- ///
- /// 指定したアイテムの位置まで移動します.
- ///
- /// アイテムのインデックス.
- /// 移動にかける秒数.
- /// ビューポート内におけるセル位置の基準. 0f(先頭) ~ 1f(末尾).
- /// 移動が完了した際に呼び出されるコールバック.
- protected virtual void ScrollTo(int index, float duration, float alignment = 0.5f, Action onComplete = null)
- {
- Scroller.ScrollTo(ToScrollerPosition(index, alignment), duration, onComplete);
- }
-
- ///
- /// 指定したアイテムの位置まで移動します.
- ///
- /// アイテムのインデックス.
- /// 移動にかける秒数.
- /// 移動に使用するイージング.
- /// ビューポート内におけるセル位置の基準. 0f(先頭) ~ 1f(末尾).
- /// 移動が完了した際に呼び出されるコールバック.
- 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);
- }
-
- ///
- /// ビューポートとコンテンツの長さに基づいてスクロールバーのサイズを更新します.
- ///
- /// ビューポートのサイズ.
- protected void UpdateScrollbarSize(float viewportLength)
- {
- var contentLength = Mathf.Max(ItemsSource.Count + (paddingHead + paddingTail - spacing) / (CellSize + spacing), 1);
- Scroller.Scrollbar.size = Scrollable ? Mathf.Clamp01(viewportLength / contentLength) : 1f;
- }
-
- ///
- /// が扱うスクロール位置を が扱うスクロール位置に変換します.
- ///
- /// が扱うスクロール位置.
- /// が扱うスクロール位置.
- protected float ToFancyScrollViewPosition(float position)
- {
- return position / Mathf.Max(ItemsSource.Count - 1, 1) * MaxScrollPosition - PaddingHeadLength;
- }
-
- ///
- /// が扱うスクロール位置を が扱うスクロール位置に変換します.
- ///
- /// が扱うスクロール位置.
- /// が扱うスクロール位置.
- protected float ToScrollerPosition(float position)
- {
- return (position + PaddingHeadLength) / MaxScrollPosition * Mathf.Max(ItemsSource.Count - 1, 1);
- }
-
- ///
- /// が扱うスクロール位置を が扱うスクロール位置に変換します.
- ///
- /// が扱うスクロール位置.
- /// ビューポート内におけるセル位置の基準. 0f(先頭) ~ 1f(末尾).
- /// が扱うスクロール位置.
- protected float ToScrollerPosition(float position, float alignment = 0.5f)
- {
- var offset = alignment * (ScrollLength - (1f + reuseCellMarginCount * 2f))
- + (1f - alignment - 0.5f) * spacing / (CellSize + spacing);
- return ToScrollerPosition(Mathf.Clamp(position - offset, 0f, MaxScrollPosition));
- }
-
- ///
- /// 指定された設定を実現するための
- /// と
- /// を計算して適用します.
- ///
- protected void AdjustCellIntervalAndScrollOffset()
- {
- var totalSize = Scroller.ViewportSize + (CellSize + spacing) * (1f + reuseCellMarginCount * 2f);
- cellInterval = (CellSize + spacing) / totalSize;
- scrollOffset = cellInterval * (1f + reuseCellMarginCount);
- }
-
- protected virtual void OnValidate()
- {
- AdjustCellIntervalAndScrollOffset();
-
- if (loop)
- {
- loop = false;
- Debug.LogError("Loop is currently not supported in FancyScrollRect.");
- }
-
- if (Scroller.SnapEnabled)
- {
- Scroller.SnapEnabled = false;
- Debug.LogError("Snap is currently not supported in FancyScrollRect.");
- }
-
- if (Scroller.MovementType == MovementType.Unrestricted)
- {
- Scroller.MovementType = MovementType.Elastic;
- Debug.LogError("MovementType.Unrestricted is currently not supported in FancyScrollRect.");
- }
- }
- }
-
- ///
- /// ScrollRect スタイルのスクロールビューを実装するための抽象基底クラス.
- /// 無限スクロールおよびスナップには対応していません.
- ///
- /// アイテムのデータ型.
- ///
- public abstract class FancyScrollRect : FancyScrollRect { }
-}
\ No newline at end of file
diff --git a/Runtime/Scripts/Layout/FancyScrollView/ScrollRect/FancyScrollRect.cs.meta b/Runtime/Scripts/Layout/FancyScrollView/ScrollRect/FancyScrollRect.cs.meta
deleted file mode 100644
index d5413e2..0000000
--- a/Runtime/Scripts/Layout/FancyScrollView/ScrollRect/FancyScrollRect.cs.meta
+++ /dev/null
@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 66c8eb84fdbde4a4a8273b98227a282d
-MonoImporter:
- externalObjects: {}
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Runtime/Scripts/Layout/FancyScrollView/ScrollRect/FancyScrollRectCell.cs b/Runtime/Scripts/Layout/FancyScrollView/ScrollRect/FancyScrollRectCell.cs
deleted file mode 100644
index d877a5f..0000000
--- a/Runtime/Scripts/Layout/FancyScrollView/ScrollRect/FancyScrollRectCell.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-/// 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);
- }
-}
\ No newline at end of file
diff --git a/Runtime/Scripts/Layout/FancyScrollView/ScrollRect/FancyScrollRectCell.cs.meta b/Runtime/Scripts/Layout/FancyScrollView/ScrollRect/FancyScrollRectCell.cs.meta
deleted file mode 100644
index 9786f4b..0000000
--- a/Runtime/Scripts/Layout/FancyScrollView/ScrollRect/FancyScrollRectCell.cs.meta
+++ /dev/null
@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 09f137a55810740eab42e24ef242dcfa
-MonoImporter:
- externalObjects: {}
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Runtime/Scripts/Layout/FancyScrollView/ScrollRect/FancyScrollRectContext.cs b/Runtime/Scripts/Layout/FancyScrollView/ScrollRect/FancyScrollRectContext.cs
deleted file mode 100644
index 8b1b0c3..0000000
--- a/Runtime/Scripts/Layout/FancyScrollView/ScrollRect/FancyScrollRectContext.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-/// Credit setchi (https://github.com/setchi)
-/// Sourced from - https://github.com/setchi/FancyScrollView
-
-using System;
-
-namespace UnityEngine.UI.Extensions
-{
- ///
- /// のコンテキスト基底クラス.
- ///
- public class FancyScrollRectContext : IFancyScrollRectContext
- {
- ScrollDirection IFancyScrollRectContext.ScrollDirection { get; set; }
- Func<(float ScrollSize, float ReuseMargin)> IFancyScrollRectContext.CalculateScrollSize { get; set; }
- }
-}
\ No newline at end of file
diff --git a/Runtime/Scripts/Layout/FancyScrollView/ScrollRect/FancyScrollRectContext.cs.meta b/Runtime/Scripts/Layout/FancyScrollView/ScrollRect/FancyScrollRectContext.cs.meta
deleted file mode 100644
index a91bebd..0000000
--- a/Runtime/Scripts/Layout/FancyScrollView/ScrollRect/FancyScrollRectContext.cs.meta
+++ /dev/null
@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 91383bd46cee541a7a03e08cfaa47c16
-MonoImporter:
- externalObjects: {}
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Runtime/Scripts/Layout/FancyScrollView/ScrollRect/IFancyScrollRectContext.cs b/Runtime/Scripts/Layout/FancyScrollView/ScrollRect/IFancyScrollRectContext.cs
deleted file mode 100644
index e40396e..0000000
--- a/Runtime/Scripts/Layout/FancyScrollView/ScrollRect/IFancyScrollRectContext.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-/// Credit setchi (https://github.com/setchi)
-/// Sourced from - https://github.com/setchi/FancyScrollView
-
-using System;
-
-namespace UnityEngine.UI.Extensions
-{
- ///
- /// のコンテキストインターフェース.
- ///
- public interface IFancyScrollRectContext
- {
- ScrollDirection ScrollDirection { get; set; }
- Func<(float ScrollSize, float ReuseMargin)> CalculateScrollSize { get; set; }
- }
-}
\ No newline at end of file
diff --git a/Runtime/Scripts/Layout/FancyScrollView/ScrollRect/IFancyScrollRectContext.cs.meta b/Runtime/Scripts/Layout/FancyScrollView/ScrollRect/IFancyScrollRectContext.cs.meta
deleted file mode 100644
index 2ae49ed..0000000
--- a/Runtime/Scripts/Layout/FancyScrollView/ScrollRect/IFancyScrollRectContext.cs.meta
+++ /dev/null
@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: e425de6354b6946c7a3b9f2c807b60fe
-MonoImporter:
- externalObjects: {}
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Runtime/Scripts/Layout/FancyScrollView/Scroller.meta b/Runtime/Scripts/Layout/FancyScrollView/Scroller.meta
deleted file mode 100644
index 0165cfd..0000000
--- a/Runtime/Scripts/Layout/FancyScrollView/Scroller.meta
+++ /dev/null
@@ -1,8 +0,0 @@
-fileFormatVersion: 2
-guid: 691a9f5ee4aec4112a01b9a4332cac51
-folderAsset: yes
-DefaultImporter:
- externalObjects: {}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Runtime/Scripts/Layout/FancyScrollView/Scroller/EasingCore.cs b/Runtime/Scripts/Layout/FancyScrollView/Scroller/EasingCore.cs
deleted file mode 100644
index 9828a81..0000000
--- a/Runtime/Scripts/Layout/FancyScrollView/Scroller/EasingCore.cs
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * EasingCore (https://github.com/setchi/EasingCore)
- * Copyright (c) 2020 setchi
- * Licensed under MIT (https://github.com/setchi/EasingCore/blob/master/LICENSE)
- */
-
-namespace UnityEngine.UI.Extensions.EasingCore
-{
- public enum Ease
- {
- Linear,
- InBack,
- InBounce,
- InCirc,
- InCubic,
- InElastic,
- InExpo,
- InQuad,
- InQuart,
- InQuint,
- InSine,
- OutBack,
- OutBounce,
- OutCirc,
- OutCubic,
- OutElastic,
- OutExpo,
- OutQuad,
- OutQuart,
- OutQuint,
- OutSine,
- InOutBack,
- InOutBounce,
- InOutCirc,
- InOutCubic,
- InOutElastic,
- InOutExpo,
- InOutQuad,
- InOutQuart,
- InOutQuint,
- InOutSine,
- }
-
- public delegate float EasingFunction(float t);
-
- public static class Easing
- {
- ///
- /// Gets the easing function
- ///
- /// Ease type
- /// Easing function
- public static EasingFunction Get(Ease type)
- {
- switch (type)
- {
- case Ease.Linear: return linear;
- case Ease.InBack: return inBack;
- case Ease.InBounce: return inBounce;
- case Ease.InCirc: return inCirc;
- case Ease.InCubic: return inCubic;
- case Ease.InElastic: return inElastic;
- case Ease.InExpo: return inExpo;
- case Ease.InQuad: return inQuad;
- case Ease.InQuart: return inQuart;
- case Ease.InQuint: return inQuint;
- case Ease.InSine: return inSine;
- case Ease.OutBack: return outBack;
- case Ease.OutBounce: return outBounce;
- case Ease.OutCirc: return outCirc;
- case Ease.OutCubic: return outCubic;
- case Ease.OutElastic: return outElastic;
- case Ease.OutExpo: return outExpo;
- case Ease.OutQuad: return outQuad;
- case Ease.OutQuart: return outQuart;
- case Ease.OutQuint: return outQuint;
- case Ease.OutSine: return outSine;
- case Ease.InOutBack: return inOutBack;
- case Ease.InOutBounce: return inOutBounce;
- case Ease.InOutCirc: return inOutCirc;
- case Ease.InOutCubic: return inOutCubic;
- case Ease.InOutElastic: return inOutElastic;
- case Ease.InOutExpo: return inOutExpo;
- case Ease.InOutQuad: return inOutQuad;
- case Ease.InOutQuart: return inOutQuart;
- case Ease.InOutQuint: return inOutQuint;
- case Ease.InOutSine: return inOutSine;
- default: return linear;
- }
-
- float linear(float t) => t;
-
- float inBack(float t) => t * t * t - t * Mathf.Sin(t * Mathf.PI);
-
- float outBack(float t) => 1f - inBack(1f - t);
-
- float inOutBack(float t) =>
- t < 0.5f
- ? 0.5f * inBack(2f * t)
- : 0.5f * outBack(2f * t - 1f) + 0.5f;
-
- float inBounce(float t) => 1f - outBounce(1f - t);
-
- float outBounce(float t) =>
- t < 4f / 11.0f ?
- (121f * t * t) / 16.0f :
- t < 8f / 11.0f ?
- (363f / 40.0f * t * t) - (99f / 10.0f * t) + 17f / 5.0f :
- t < 9f / 10.0f ?
- (4356f / 361.0f * t * t) - (35442f / 1805.0f * t) + 16061f / 1805.0f :
- (54f / 5.0f * t * t) - (513f / 25.0f * t) + 268f / 25.0f;
-
- float inOutBounce(float t) =>
- t < 0.5f
- ? 0.5f * inBounce(2f * t)
- : 0.5f * outBounce(2f * t - 1f) + 0.5f;
-
- float inCirc(float t) => 1f - Mathf.Sqrt(1f - (t * t));
-
- float outCirc(float t) => Mathf.Sqrt((2f - t) * t);
-
- float inOutCirc(float t) =>
- t < 0.5f
- ? 0.5f * (1 - Mathf.Sqrt(1f - 4f * (t * t)))
- : 0.5f * (Mathf.Sqrt(-((2f * t) - 3f) * ((2f * t) - 1f)) + 1f);
-
- float inCubic(float t) => t * t * t;
-
- float outCubic(float t) => inCubic(t - 1f) + 1f;
-
- float inOutCubic(float t) =>
- t < 0.5f
- ? 4f * t * t * t
- : 0.5f * inCubic(2f * t - 2f) + 1f;
-
- float inElastic(float t) => Mathf.Sin(13f * (Mathf.PI * 0.5f) * t) * Mathf.Pow(2f, 10f * (t - 1f));
-
- float outElastic(float t) => Mathf.Sin(-13f * (Mathf.PI * 0.5f) * (t + 1)) * Mathf.Pow(2f, -10f * t) + 1f;
-
- float inOutElastic(float t) =>
- t < 0.5f
- ? 0.5f * Mathf.Sin(13f * (Mathf.PI * 0.5f) * (2f * t)) * Mathf.Pow(2f, 10f * ((2f * t) - 1f))
- : 0.5f * (Mathf.Sin(-13f * (Mathf.PI * 0.5f) * ((2f * t - 1f) + 1f)) * Mathf.Pow(2f, -10f * (2f * t - 1f)) + 2f);
-
- float inExpo(float t) => Mathf.Approximately(0.0f, t) ? t : Mathf.Pow(2f, 10f * (t - 1f));
-
- float outExpo(float t) => Mathf.Approximately(1.0f, t) ? t : 1f - Mathf.Pow(2f, -10f * t);
-
- float inOutExpo(float v) =>
- Mathf.Approximately(0.0f, v) || Mathf.Approximately(1.0f, v)
- ? v
- : v < 0.5f
- ? 0.5f * Mathf.Pow(2f, (20f * v) - 10f)
- : -0.5f * Mathf.Pow(2f, (-20f * v) + 10f) + 1f;
-
- float inQuad(float t) => t * t;
-
- float outQuad(float t) => -t * (t - 2f);
-
- float inOutQuad(float t) =>
- t < 0.5f
- ? 2f * t * t
- : -2f * t * t + 4f * t - 1f;
-
- float inQuart(float t) => t * t * t * t;
-
- float outQuart(float t)
- {
- var u = t - 1f;
- return u * u * u * (1f - t) + 1f;
- }
-
- float inOutQuart(float t) =>
- t < 0.5f
- ? 8f * inQuart(t)
- : -8f * inQuart(t - 1f) + 1f;
-
- float inQuint(float t) => t * t * t * t * t;
-
- float outQuint(float t) => inQuint(t - 1f) + 1f;
-
- float inOutQuint(float t) =>
- t < 0.5f
- ? 16f * inQuint(t)
- : 0.5f * inQuint(2f * t - 2f) + 1f;
-
- float inSine(float t) => Mathf.Sin((t - 1f) * (Mathf.PI * 0.5f)) + 1f;
-
- float outSine(float t) => Mathf.Sin(t * (Mathf.PI * 0.5f));
-
- float inOutSine(float t) => 0.5f * (1f - Mathf.Cos(t * Mathf.PI));
- }
- }
-}
\ No newline at end of file
diff --git a/Runtime/Scripts/Layout/FancyScrollView/Scroller/EasingCore.cs.meta b/Runtime/Scripts/Layout/FancyScrollView/Scroller/EasingCore.cs.meta
deleted file mode 100644
index 0a1d19c..0000000
--- a/Runtime/Scripts/Layout/FancyScrollView/Scroller/EasingCore.cs.meta
+++ /dev/null
@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 3b2a35f9ff1c8487582b74620e380486
-MonoImporter:
- externalObjects: {}
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Runtime/Scripts/Layout/FancyScrollView/Scroller/MovementDirection.cs b/Runtime/Scripts/Layout/FancyScrollView/Scroller/MovementDirection.cs
deleted file mode 100644
index 5a41163..0000000
--- a/Runtime/Scripts/Layout/FancyScrollView/Scroller/MovementDirection.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-/// Credit setchi (https://github.com/setchi)
-/// Sourced from - https://github.com/setchi/FancyScrollView
-
-namespace UnityEngine.UI.Extensions
-{
- public enum MovementDirection
- {
- Left,
- Right,
- Up,
- Down,
- }
-}
\ No newline at end of file
diff --git a/Runtime/Scripts/Layout/FancyScrollView/Scroller/MovementDirection.cs.meta b/Runtime/Scripts/Layout/FancyScrollView/Scroller/MovementDirection.cs.meta
deleted file mode 100644
index e13bcff..0000000
--- a/Runtime/Scripts/Layout/FancyScrollView/Scroller/MovementDirection.cs.meta
+++ /dev/null
@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 11769de5e972543c7a4132ceff94a5c4
-MonoImporter:
- externalObjects: {}
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Runtime/Scripts/Layout/FancyScrollView/Scroller/MovementType.cs b/Runtime/Scripts/Layout/FancyScrollView/Scroller/MovementType.cs
deleted file mode 100644
index cb8c210..0000000
--- a/Runtime/Scripts/Layout/FancyScrollView/Scroller/MovementType.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-/// Credit setchi (https://github.com/setchi)
-/// Sourced from - https://github.com/setchi/FancyScrollView
-
-namespace UnityEngine.UI.Extensions
-{
- public enum MovementType
- {
- Unrestricted = ScrollRect.MovementType.Unrestricted,
- Elastic = ScrollRect.MovementType.Elastic,
- Clamped = ScrollRect.MovementType.Clamped
- }
-}
\ No newline at end of file
diff --git a/Runtime/Scripts/Layout/FancyScrollView/Scroller/MovementType.cs.meta b/Runtime/Scripts/Layout/FancyScrollView/Scroller/MovementType.cs.meta
deleted file mode 100644
index 9bd990b..0000000
--- a/Runtime/Scripts/Layout/FancyScrollView/Scroller/MovementType.cs.meta
+++ /dev/null
@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 585de8f4f272547c89041f94f2ad92b8
-MonoImporter:
- externalObjects: {}
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Runtime/Scripts/Layout/FancyScrollView/Scroller/ScrollDirection.cs b/Runtime/Scripts/Layout/FancyScrollView/Scroller/ScrollDirection.cs
deleted file mode 100644
index 81a14ff..0000000
--- a/Runtime/Scripts/Layout/FancyScrollView/Scroller/ScrollDirection.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-/// Credit setchi (https://github.com/setchi)
-/// Sourced from - https://github.com/setchi/FancyScrollView
-
-namespace UnityEngine.UI.Extensions
-{
- public enum ScrollDirection
- {
- Vertical,
- Horizontal,
- }
-}
\ No newline at end of file
diff --git a/Runtime/Scripts/Layout/FancyScrollView/Scroller/ScrollDirection.cs.meta b/Runtime/Scripts/Layout/FancyScrollView/Scroller/ScrollDirection.cs.meta
deleted file mode 100644
index a4f7b43..0000000
--- a/Runtime/Scripts/Layout/FancyScrollView/Scroller/ScrollDirection.cs.meta
+++ /dev/null
@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 3392a30c085c642139c92e94ec0d6309
-MonoImporter:
- externalObjects: {}
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Runtime/Scripts/Layout/FancyScrollView/Scroller/Scroller.cs b/Runtime/Scripts/Layout/FancyScrollView/Scroller/Scroller.cs
deleted file mode 100644
index b491d13..0000000
--- a/Runtime/Scripts/Layout/FancyScrollView/Scroller/Scroller.cs
+++ /dev/null
@@ -1,597 +0,0 @@
-/// Credit setchi (https://github.com/setchi)
-/// Sourced from - https://github.com/setchi/FancyScrollView
-
-using System;
-using UnityEngine.EventSystems;
-using UnityEngine.UI.Extensions.EasingCore;
-
-namespace UnityEngine.UI.Extensions
-{
- ///
- /// スクロール位置の制御を行うコンポーネント.
- ///
- public class Scroller : UIBehaviour, IPointerUpHandler, IPointerDownHandler, IBeginDragHandler, IEndDragHandler, IDragHandler, IScrollHandler
- {
- [SerializeField] RectTransform viewport = default;
-
- ///
- /// ビューポートのサイズ.
- ///
- public float ViewportSize => scrollDirection == ScrollDirection.Horizontal
- ? viewport.rect.size.x
- : viewport.rect.size.y;
-
- [SerializeField] ScrollDirection scrollDirection = ScrollDirection.Vertical;
-
- ///
- /// スクロール方向.
- ///
- public ScrollDirection ScrollDirection => scrollDirection;
-
- [SerializeField] MovementType movementType = MovementType.Elastic;
-
- ///
- /// コンテンツがスクロール範囲を越えて移動するときに使用する挙動.
- ///
- public MovementType MovementType
- {
- get => movementType;
- set => movementType = value;
- }
-
- [SerializeField] float elasticity = 0.1f;
-
- ///
- /// コンテンツがスクロール範囲を越えて移動するときに使用する弾力性の量.
- ///
- public float Elasticity
- {
- get => elasticity;
- set => elasticity = value;
- }
-
- [SerializeField] float scrollSensitivity = 1f;
-
- ///
- /// の端から端まで Drag したときのスクロール位置の変化量.
- ///
- public float ScrollSensitivity
- {
- get => scrollSensitivity;
- set => scrollSensitivity = value;
- }
-
- [SerializeField] bool inertia = true;
-
- ///
- /// 慣性を使用するかどうか. true を指定すると慣性が有効に, false を指定すると慣性が無効になります.
- ///
- public bool Inertia
- {
- get => inertia;
- set => inertia = value;
- }
-
- [SerializeField] float decelerationRate = 0.03f;
-
- ///
- /// スクロールの減速率. が true の場合のみ有効です.
- ///
- public float DecelerationRate
- {
- get => decelerationRate;
- set => decelerationRate = value;
- }
-
- [SerializeField] Snap snap = new Snap {
- Enable = true,
- VelocityThreshold = 0.5f,
- Duration = 0.3f,
- Easing = Ease.InOutCubic
- };
-
- ///
- /// true ならスナップし, falseならスナップしません.
- ///
- ///
- /// スナップを有効にすると, 慣性でスクロールが止まる直前に最寄りのセルへ移動します.
- ///
- public bool SnapEnabled
- {
- get => snap.Enable;
- set => snap.Enable = value;
- }
-
- [SerializeField] bool draggable = true;
-
- ///
- /// Drag 入力を受付けるかどうか.
- ///
- public bool Draggable
- {
- get => draggable;
- set => draggable = value;
- }
-
- [SerializeField] Scrollbar scrollbar = default;
-
- ///
- /// スクロールバーのオブジェクト.
- ///
- public Scrollbar Scrollbar => scrollbar;
-
- ///
- /// 現在のスクロール位置.
- ///
- ///
- public float Position
- {
- get => currentPosition;
- set
- {
- autoScrollState.Reset();
- velocity = 0f;
- dragging = false;
-
- UpdatePosition(value);
- }
- }
-
- readonly AutoScrollState autoScrollState = new AutoScrollState();
-
- Action onValueChanged;
- Action onSelectionChanged;
-
- Vector2 beginDragPointerPosition;
- float scrollStartPosition;
- float prevPosition;
- float currentPosition;
-
- int totalCount;
-
- bool hold;
- bool scrolling;
- bool dragging;
- float velocity;
-
- [Serializable]
- class Snap
- {
- public bool Enable;
- public float VelocityThreshold;
- public float Duration;
- public Ease Easing;
- }
-
- static readonly EasingFunction DefaultEasingFunction = Easing.Get(Ease.OutCubic);
-
- class AutoScrollState
- {
- public bool Enable;
- public bool Elastic;
- public float Duration;
- public EasingFunction EasingFunction;
- public float StartTime;
- public float EndPosition;
-
- public Action OnComplete;
-
- public void Reset()
- {
- Enable = false;
- Elastic = false;
- Duration = 0f;
- StartTime = 0f;
- EasingFunction = DefaultEasingFunction;
- EndPosition = 0f;
- OnComplete = null;
- }
-
- public void Complete()
- {
- OnComplete?.Invoke();
- Reset();
- }
- }
-
- protected override void Start()
- {
- base.Start();
-
- if (scrollbar)
- {
- scrollbar.onValueChanged.AddListener(x => UpdatePosition(x * (totalCount - 1f), false));
- }
- }
-
- ///
- /// スクロール位置が変化したときのコールバックを設定します.
- ///
- /// スクロール位置が変化したときのコールバック.
- public void OnValueChanged(Action callback) => onValueChanged = callback;
-
- ///
- /// 選択位置が変化したときのコールバックを設定します.
- ///
- /// 選択位置が変化したときのコールバック.
- public void OnSelectionChanged(Action callback) => onSelectionChanged = callback;
-
- ///
- /// アイテムの総数を設定します.
- ///
- ///
- /// を元に最大スクロール位置を計算します.
- ///
- /// アイテムの総数.
- public void SetTotalCount(int totalCount) => this.totalCount = totalCount;
-
- ///
- /// 指定した位置まで移動します.
- ///
- /// スクロール位置. 0f ~ totalCount - 1f の範囲.
- /// 移動にかける秒数.
- /// 移動が完了した際に呼び出されるコールバック.
- public void ScrollTo(float position, float duration, Action onComplete = null) => ScrollTo(position, duration, Ease.OutCubic, onComplete);
-
- ///
- /// 指定した位置まで移動します.
- ///
- /// スクロール位置. 0f ~ totalCount - 1f の範囲.
- /// 移動にかける秒数.
- /// 移動に使用するイージング.
- /// 移動が完了した際に呼び出されるコールバック.
- public void ScrollTo(float position, float duration, Ease easing, Action onComplete = null) => ScrollTo(position, duration, Easing.Get(easing), onComplete);
-
- ///
- /// 指定した位置まで移動します.
- ///
- /// スクロール位置. 0f ~ totalCount - 1f の範囲.
- /// 移動にかける秒数.
- /// 移動に使用するイージング関数.
- /// 移動が完了した際に呼び出されるコールバック.
- public void ScrollTo(float position, float duration, EasingFunction easingFunction, Action onComplete = null)
- {
- if (duration <= 0f)
- {
- Position = CircularPosition(position, totalCount);
- onComplete?.Invoke();
- return;
- }
-
- autoScrollState.Reset();
- autoScrollState.Enable = true;
- autoScrollState.Duration = duration;
- autoScrollState.EasingFunction = easingFunction ?? DefaultEasingFunction;
- autoScrollState.StartTime = Time.unscaledTime;
- autoScrollState.EndPosition = currentPosition + CalculateMovementAmount(currentPosition, position);
- autoScrollState.OnComplete = onComplete;
-
- velocity = 0f;
- scrollStartPosition = currentPosition;
-
- UpdateSelection(Mathf.RoundToInt(CircularPosition(autoScrollState.EndPosition, totalCount)));
- }
-
- ///
- /// 指定したインデックスの位置までジャンプします.
- ///
- /// アイテムのインデックス.
- public void JumpTo(int index)
- {
- if (index < 0 || index > totalCount - 1)
- {
- throw new ArgumentOutOfRangeException(nameof(index));
- }
-
- UpdateSelection(index);
- Position = index;
- }
-
- ///
- /// から に移動する際の移動方向を返します.
- /// スクロール範囲が無制限に設定されている場合は, 最短距離の移動方向を返します.
- ///
- /// 移動元のインデックス.
- /// 移動先のインデックス.
- ///
- public MovementDirection GetMovementDirection(int sourceIndex, int destIndex)
- {
- var movementAmount = CalculateMovementAmount(sourceIndex, destIndex);
- return scrollDirection == ScrollDirection.Horizontal
- ? movementAmount > 0
- ? MovementDirection.Left
- : MovementDirection.Right
- : movementAmount > 0
- ? MovementDirection.Up
- : MovementDirection.Down;
- }
-
- ///
- void IPointerDownHandler.OnPointerDown(PointerEventData eventData)
- {
- if (!draggable || eventData.button != PointerEventData.InputButton.Left)
- {
- return;
- }
-
- hold = true;
- velocity = 0f;
- autoScrollState.Reset();
- }
-
- ///
- void IPointerUpHandler.OnPointerUp(PointerEventData eventData)
- {
- if (!draggable || eventData.button != PointerEventData.InputButton.Left)
- {
- return;
- }
-
- if (hold && snap.Enable)
- {
- UpdateSelection(Mathf.RoundToInt(CircularPosition(currentPosition, totalCount)));
- ScrollTo(Mathf.RoundToInt(currentPosition), snap.Duration, snap.Easing);
- }
-
- hold = false;
- }
-
- ///
- void IScrollHandler.OnScroll(PointerEventData eventData)
- {
- if (!draggable)
- {
- return;
- }
-
- var delta = eventData.scrollDelta;
-
- // Down is positive for scroll events, while in UI system up is positive.
- delta.y *= -1;
- var scrollDelta = scrollDirection == ScrollDirection.Horizontal
- ? Mathf.Abs(delta.y) > Mathf.Abs(delta.x)
- ? delta.y
- : delta.x
- : Mathf.Abs(delta.x) > Mathf.Abs(delta.y)
- ? delta.x
- : delta.y;
-
- if (eventData.IsScrolling())
- {
- scrolling = true;
- }
-
- var position = currentPosition + scrollDelta / ViewportSize * scrollSensitivity;
- if (movementType == MovementType.Clamped)
- {
- position += CalculateOffset(position);
- }
-
- if (autoScrollState.Enable)
- {
- autoScrollState.Reset();
- }
-
- UpdatePosition(position);
- }
-
- ///
- void IBeginDragHandler.OnBeginDrag(PointerEventData eventData)
- {
- if (!draggable || eventData.button != PointerEventData.InputButton.Left)
- {
- return;
- }
-
- hold = false;
- RectTransformUtility.ScreenPointToLocalPointInRectangle(
- viewport,
- eventData.position,
- eventData.pressEventCamera,
- out beginDragPointerPosition);
-
- scrollStartPosition = currentPosition;
- dragging = true;
- autoScrollState.Reset();
- }
-
- ///
- void IDragHandler.OnDrag(PointerEventData eventData)
- {
- if (!draggable || eventData.button != PointerEventData.InputButton.Left || !dragging)
- {
- return;
- }
-
- if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(
- viewport,
- eventData.position,
- eventData.pressEventCamera,
- out var dragPointerPosition))
- {
- return;
- }
-
- var pointerDelta = dragPointerPosition - beginDragPointerPosition;
- var position = (scrollDirection == ScrollDirection.Horizontal ? -pointerDelta.x : pointerDelta.y)
- / ViewportSize
- * scrollSensitivity
- + scrollStartPosition;
-
- var offset = CalculateOffset(position);
- position += offset;
-
- if (movementType == MovementType.Elastic)
- {
- if (offset != 0f)
- {
- position -= RubberDelta(offset, scrollSensitivity);
- }
- }
-
- UpdatePosition(position);
- }
-
- ///
- void IEndDragHandler.OnEndDrag(PointerEventData eventData)
- {
- if (!draggable || eventData.button != PointerEventData.InputButton.Left)
- {
- return;
- }
-
- dragging = false;
- }
-
- float CalculateOffset(float position)
- {
- if (movementType == MovementType.Unrestricted)
- {
- return 0f;
- }
-
- if (position < 0f)
- {
- return -position;
- }
-
- if (position > totalCount - 1)
- {
- return totalCount - 1 - position;
- }
-
- return 0f;
- }
-
- void UpdatePosition(float position, bool updateScrollbar = true)
- {
- onValueChanged?.Invoke(currentPosition = position);
-
- if (scrollbar && updateScrollbar)
- {
- scrollbar.value = Mathf.Clamp01(position / Mathf.Max(totalCount - 1f, 1e-4f));
- }
- }
-
- void UpdateSelection(int index) => onSelectionChanged?.Invoke(index);
-
- float RubberDelta(float overStretching, float viewSize) =>
- (1 - 1 / (Mathf.Abs(overStretching) * 0.55f / viewSize + 1)) * viewSize * Mathf.Sign(overStretching);
-
- void Update()
- {
- var deltaTime = Time.unscaledDeltaTime;
- var offset = CalculateOffset(currentPosition);
-
- if (autoScrollState.Enable)
- {
- var position = 0f;
-
- if (autoScrollState.Elastic)
- {
- position = Mathf.SmoothDamp(currentPosition, currentPosition + offset, ref velocity,
- elasticity, Mathf.Infinity, deltaTime);
-
- if (Mathf.Abs(velocity) < 0.01f)
- {
- position = Mathf.Clamp(Mathf.RoundToInt(position), 0, totalCount - 1);
- velocity = 0f;
- autoScrollState.Complete();
- }
- }
- else
- {
- var alpha = Mathf.Clamp01((Time.unscaledTime - autoScrollState.StartTime) /
- Mathf.Max(autoScrollState.Duration, float.Epsilon));
- position = Mathf.LerpUnclamped(scrollStartPosition, autoScrollState.EndPosition,
- autoScrollState.EasingFunction(alpha));
-
- if (Mathf.Approximately(alpha, 1f))
- {
- autoScrollState.Complete();
- }
- }
-
- UpdatePosition(position);
- }
- else if (!(dragging || scrolling) && (!Mathf.Approximately(offset, 0f) || !Mathf.Approximately(velocity, 0f)))
- {
- var position = currentPosition;
-
- if (movementType == MovementType.Elastic && !Mathf.Approximately(offset, 0f))
- {
- autoScrollState.Reset();
- autoScrollState.Enable = true;
- autoScrollState.Elastic = true;
-
- UpdateSelection(Mathf.Clamp(Mathf.RoundToInt(position), 0, totalCount - 1));
- }
- else if (inertia)
- {
- velocity *= Mathf.Pow(decelerationRate, deltaTime);
-
- if (Mathf.Abs(velocity) < 0.001f)
- {
- velocity = 0f;
- }
-
- position += velocity * deltaTime;
-
- if (snap.Enable && Mathf.Abs(velocity) < snap.VelocityThreshold)
- {
- ScrollTo(Mathf.RoundToInt(currentPosition), snap.Duration, snap.Easing);
- }
- }
- else
- {
- velocity = 0f;
- }
-
- if (!Mathf.Approximately(velocity, 0f))
- {
- if (movementType == MovementType.Clamped)
- {
- offset = CalculateOffset(position);
- position += offset;
-
- if (Mathf.Approximately(position, 0f) || Mathf.Approximately(position, totalCount - 1f))
- {
- velocity = 0f;
- UpdateSelection(Mathf.RoundToInt(position));
- }
- }
-
- UpdatePosition(position);
- }
- }
-
- if (!autoScrollState.Enable && (dragging || scrolling) && inertia)
- {
- var newVelocity = (currentPosition - prevPosition) / deltaTime;
- velocity = Mathf.Lerp(velocity, newVelocity, deltaTime * 10f);
- }
-
- prevPosition = currentPosition;
- scrolling = false;
- }
-
- float CalculateMovementAmount(float sourcePosition, float destPosition)
- {
- if (movementType != MovementType.Unrestricted)
- {
- return Mathf.Clamp(destPosition, 0, totalCount - 1) - sourcePosition;
- }
-
- var amount = CircularPosition(destPosition, totalCount) - CircularPosition(sourcePosition, totalCount);
-
- if (Mathf.Abs(amount) > totalCount * 0.5f)
- {
- amount = Mathf.Sign(-amount) * (totalCount - Mathf.Abs(amount));
- }
-
- return amount;
- }
-
- float CircularPosition(float p, int size) => size < 1 ? 0 : p < 0 ? size - 1 + (p + 1) % size : p % size;
- }
-}
\ No newline at end of file
diff --git a/Runtime/Scripts/Layout/FancyScrollView/Scroller/Scroller.cs.meta b/Runtime/Scripts/Layout/FancyScrollView/Scroller/Scroller.cs.meta
deleted file mode 100644
index 731287d..0000000
--- a/Runtime/Scripts/Layout/FancyScrollView/Scroller/Scroller.cs.meta
+++ /dev/null
@@ -1,12 +0,0 @@
-fileFormatVersion: 2
-guid: 9f0e995f494626a4f878eedbded37c8d
-timeCreated: 1487408581
-licenseType: Free
-MonoImporter:
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant: