Question by
osterzone · Feb 09, 2020 at 01:36 AM ·
draggingmouse drag
Drag mouse to cycle through images
Hi all,
Trying to accomplish something relatively simple here. I need to scroll up (index++) on the image stack when I drag up, and scroll down (index--) on the images when I drag down. I have written this code here which should work, but I can't figure out why it doesn't. (note that m_Selected == true when pointer enters the image rect)
if (m_Selected == true)
{
if (Input.GetMouseButtonDown(0))
{
mouseDownPos = Input.mousePosition;
if (Input.mousePosition.y > mouseDownPos.y)
{
if (m_Index <= 0)
{
m_Index = 0;
}
else
{
m_Index--;
}
UpdateImage();
}
else if (Input.mousePosition.y < mouseDownPos.y)
{
if (m_Index >= max)
{
m_Index = max;
}
else
{
m_Index++;
}
UpdateImage();
}
}
}
Any help would be much appreciated!
Comment