diff --git a/Editor/FancyScrollView/ScrollerEditor.cs b/Editor/FancyScrollView/ScrollerEditor.cs index 2d4982f..34673e3 100644 --- a/Editor/FancyScrollView/ScrollerEditor.cs +++ b/Editor/FancyScrollView/ScrollerEditor.cs @@ -4,8 +4,6 @@ using UnityEditor; using UnityEditor.AnimatedValues; -// For maintenance, every new [SerializeField] variable in Scroller must be declared here - namespace UnityEngine.UI.Extensions { [CustomEditor(typeof(Scroller))] @@ -20,16 +18,11 @@ namespace UnityEngine.UI.Extensions SerializedProperty inertia; SerializedProperty decelerationRate; SerializedProperty snap; - SerializedProperty snapEnable; - SerializedProperty snapVelocityThreshold; - SerializedProperty snapDuration; - SerializedProperty snapEasing; SerializedProperty draggable; SerializedProperty scrollbar; AnimBool showElasticity; AnimBool showInertiaRelatedValues; - AnimBool showSnapEnableRelatedValues; void OnEnable() { @@ -41,16 +34,11 @@ namespace UnityEngine.UI.Extensions inertia = serializedObject.FindProperty("inertia"); decelerationRate = serializedObject.FindProperty("decelerationRate"); snap = serializedObject.FindProperty("snap"); - snapEnable = serializedObject.FindProperty("snap.Enable"); - snapVelocityThreshold = serializedObject.FindProperty("snap.VelocityThreshold"); - snapDuration = serializedObject.FindProperty("snap.Duration"); - snapEasing = serializedObject.FindProperty("snap.Easing"); draggable = serializedObject.FindProperty("draggable"); scrollbar = serializedObject.FindProperty("scrollbar"); showElasticity = new AnimBool(Repaint); showInertiaRelatedValues = new AnimBool(Repaint); - showSnapEnableRelatedValues = new AnimBool(Repaint); SetAnimBools(true); } @@ -58,14 +46,12 @@ namespace UnityEngine.UI.Extensions { showElasticity.valueChanged.RemoveListener(Repaint); showInertiaRelatedValues.valueChanged.RemoveListener(Repaint); - showSnapEnableRelatedValues.valueChanged.RemoveListener(Repaint); } void SetAnimBools(bool instant) { SetAnimBool(showElasticity, !movementType.hasMultipleDifferentValues && movementType.enumValueIndex == (int)MovementType.Elastic, instant); SetAnimBool(showInertiaRelatedValues, !inertia.hasMultipleDifferentValues && inertia.boolValue, instant); - SetAnimBool(showSnapEnableRelatedValues, !snapEnable.hasMultipleDifferentValues && snapEnable.boolValue, instant); } void SetAnimBool(AnimBool a, bool value, bool instant) @@ -126,31 +112,6 @@ namespace UnityEngine.UI.Extensions { EditorGUILayout.PropertyField(decelerationRate); EditorGUILayout.PropertyField(snap); - - using (new EditorGUI.IndentLevelScope()) - { - DrawSnapRelatedValues(); - } - } - } - } - - void DrawSnapRelatedValues() - { - if (snap.isExpanded) - { - EditorGUILayout.PropertyField(snapEnable); - - using (var group = new EditorGUILayout.FadeGroupScope(showSnapEnableRelatedValues.faded)) - { - if (!group.visible) - { - return; - } - - EditorGUILayout.PropertyField(snapVelocityThreshold); - EditorGUILayout.PropertyField(snapDuration); - EditorGUILayout.PropertyField(snapEasing); } } } diff --git a/Runtime/Scripts/Layout/FancyScrollView/Core/FancyCell.cs b/Runtime/Scripts/Layout/FancyScrollView/Core/FancyCell.cs index 17928d1..f32e26b 100644 --- a/Runtime/Scripts/Layout/FancyScrollView/Core/FancyCell.cs +++ b/Runtime/Scripts/Layout/FancyScrollView/Core/FancyCell.cs @@ -1,7 +1,6 @@ /// Credit setchi (https://github.com/setchi) /// Sourced from - https://github.com/setchi/FancyScrollView - namespace UnityEngine.UI.Extensions { /// diff --git a/Runtime/Scripts/Layout/FancyScrollView/ScrollRect/FancyScrollRect.cs b/Runtime/Scripts/Layout/FancyScrollView/ScrollRect/FancyScrollRect.cs index 57ba6bb..732abe0 100644 --- a/Runtime/Scripts/Layout/FancyScrollView/ScrollRect/FancyScrollRect.cs +++ b/Runtime/Scripts/Layout/FancyScrollView/ScrollRect/FancyScrollRect.cs @@ -101,7 +101,7 @@ namespace UnityEngine.UI.Extensions /// のスクロール位置. void OnScrollerValueChanged(float p) { - base.UpdatePosition(Scrollable ? ToFancyScrollViewPosition(p) : 0f); + base.UpdatePosition(ToFancyScrollViewPosition(Scrollable ? p : 0f)); if (Scroller.Scrollbar) { @@ -161,8 +161,6 @@ namespace UnityEngine.UI.Extensions /// protected override void UpdateContents(IList items) { - Debug.Assert(Context.CalculateScrollSize != null); - AdjustCellIntervalAndScrollOffset(); base.UpdateContents(items); diff --git a/Runtime/Scripts/Layout/FancyScrollView/ScrollRect/FancyScrollRectCell.cs b/Runtime/Scripts/Layout/FancyScrollView/ScrollRect/FancyScrollRectCell.cs index 4b25d5b..d877a5f 100644 --- a/Runtime/Scripts/Layout/FancyScrollView/ScrollRect/FancyScrollRectCell.cs +++ b/Runtime/Scripts/Layout/FancyScrollView/ScrollRect/FancyScrollRectCell.cs @@ -53,4 +53,4 @@ namespace UnityEngine.UI.Extensions /// public sealed override void SetContext(FancyScrollRectContext context) => base.SetContext(context); } -} +} \ No newline at end of file diff --git a/Runtime/Scripts/Layout/FancyScrollView/Scroller/Scroller.cs b/Runtime/Scripts/Layout/FancyScrollView/Scroller/Scroller.cs index ea0c276..b491d13 100644 --- a/Runtime/Scripts/Layout/FancyScrollView/Scroller/Scroller.cs +++ b/Runtime/Scripts/Layout/FancyScrollView/Scroller/Scroller.cs @@ -329,7 +329,7 @@ namespace UnityEngine.UI.Extensions if (hold && snap.Enable) { - UpdateSelection(Mathf.Clamp(Mathf.RoundToInt(currentPosition), 0, totalCount - 1)); + UpdateSelection(Mathf.RoundToInt(CircularPosition(currentPosition, totalCount))); ScrollTo(Mathf.RoundToInt(currentPosition), snap.Duration, snap.Easing); }