Playmaker Forum

Playmaker Help & Tips => Android Help => Topic started by: Shawn Kilian on August 15, 2017, 07:09:24 AM

Title: Gesture Scrolling Limit on Android [SOLVED]
Post by: Shawn Kilian on August 15, 2017, 07:09:24 AM
Hello,

How can I limit the scrolling of a gesture swipe event?  When I swipe up, my screen scrolls down but it doesn't know when it's reached the end of the screen so it just keeps on going.  Whenever I put a float clamp on it, that works but not for every device since each device has a different screen width/height.  I tried using Get Screen Width and Get Screen Height but the values returned are always zero.

Am I doing this the wrong way?  I just want to swipe down to the bottom of my phones screen, then swipe up to go back to the top.  I figured it would be simple but I think I'm complicating it.  Please help!!!
Title: Re: Gesture Scrolling Limit on Android
Post by: Shawn Kilian on August 16, 2017, 06:20:08 AM
I figured out how to do it.  You don't need PlayMaker to achieve this functionality.  In fact you don't even need to use the Gesture Action at all.

Simply add an Image (Script) component in combination with a Mask (Script) component to the CONTENT (not the canvas), effectively limiting the scrolling of the view-port to whatever the mask can see within that canvas. It's perfect!

Note:  Make sure your CONTENT is a child of the CANVAS.  The CANVAS needs a Scroll Rect (Script) component where you reference the "Content" and "Viewport".

You can watch a video tutorial here https://unity3d.com/learn/tutorials/modules/beginner/ui/ui-scroll-rect (https://unity3d.com/learn/tutorials/modules/beginner/ui/ui-scroll-rect)