-
Hello! I have a question regarding the scrolling in ScrollingList. I have 5 buttons which I am scrolling through linearly (horizontally), and I want to make it such a way when button is pressed it is centered and gets elevated slightly, that it is to show user that the button is clicked. This script is attached to every listBox element public IEnumerator JumpAnimation(float units = 7f)
{
isAnimationRunning = true;
// Can't click other buttons while animation proceeds
BlockInteractionWithButtons();
// Wait so that button is centered
yield return new WaitForSeconds(0.4f); // <1>
// newPosition is above it's previous position
Vector3 newPosition = new(rectTransform.position.x, rectTransform.position.y + units, rectTransform.position.z); // <2>
// Smoothing animation
while (newPosition != rectTransform.position)
{
rectTransform.position = Vector3.MoveTowards(
rectTransform.position,
newPosition,
animationSpeed);
yield return null;
}
// As soon as animation finishes, user can click other buttons
EnableInteractionWithButtons();
isAnimationRunning = false;
} I want to make sure that user can't scroll through the list while animation is active, if I don't do so, user can create a mess by clicking a button and then quickly scrolling (this results in button moving towards the wrong place diagonally, without going back to normal) At |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi, For 1. when the movement of the list is ended, it will send public void MoveOneUnitUp()
{
if (_hasNoContent || _blockInput)
return;
...
} |
Beta Was this translation helpful? Give feedback.
Hi, For 1. when the movement of the list is ended, it will send
OnMovementEnd
event.For 2. add a flag (i.e.
_blockInput
) to theCircularScrollingList.cs
, and create a function to toggle this flag.Then check the flag in the following functions:
MoveOneUnitUp
,MoveOneUnitDown
,OnBeginDrag
,OnDrag
,OnEndDrag
, andOnScroll
. It will be like: