Scroll View 2D In Only 1 Direction
AnsweredHi,
If I want to have a touch point that, when the user touches and swipes up, some menu expands, I am currently trying to use a scroll view 2d for this, but I can't see a way to lock the swiping to only trigger when swiping up. Currently I have it locked to only the y-axis, but that means swiping down also opens the menu. Is there a better way to implement this or a way to make it work how I currently have it implemented?
Thanks!
-
Good Day Mason,
I will additionally follow up in a private message on this.
A simple way to achieve this is to use "Node Components" and use triggers with custom conditions.
You can add a temp value to the container node. This we will use as a delay identifier.
On the scroll View 2D, create a trigger for "On Property Change" with an action that sets the temp value on your container node with the Y position of the scroll position. The key point is to set it on a few milisecond delay. This will provide to you a number that the scroll position was at just a few frames ago.
Then you compare that temp value to the real value of the scroll position.
Now that you have a comparison you can decide the behavior if the value is smaller, or if it is larger. Perhaps, if smaller the container closes, and that can be a state manager state, and if larger then it opens the container.
I hope this helps.1
Please sign in to leave a comment.
Comments
1 comment