I would like detect scrolling up or down. Should be like Windows Form below.
private void dgv_Scroll(object sender, ScrollEventArgs e)
{
if (e.OldValue > e.NewValue)
{
// here up
}
else
{
// here down
}
}
How to detect scrolling up or down in panel for Unity3d ?
public void OnScrollValueChanged(float value)
{
if (?)
{
// here up
}
else
{
// here down
}
}
There is
onValueChanged
forScrollbar
andScrollRect
. Don't know which one you are using but here is a sample code to register to theonValueChanged
event. You can find other UI events examples here. Will modify it to include samples from this answer.You likely need the
Scrollbar
. Get the original value, on start then compare it with the current value when scrolling. You can use that to determine up and down. This assumes that thedirection
is set toTopToBottom
.Scrollbar:
ScrollRect: