Update: Have created a public Github repo for updates and improvements.
I’ve been trying to perfect the screen swiping feature in Unity. For a while I was using Unity-UI-Extensions’ HorizontalScrollSnap which is really good and it did the trick for a while. However, I always felt it was a little off. I couldn’t figure out the threshold values to get it stop skipping screen and sometimes the screens would get stuck, etc. So I have attempted to make my own screen/page snapping with swipe gestures and also button control. The pagination toggles can also change screen/page upon click.
I can’t take all the credit for my script though as a good chunk of it is code from Unity’s ScrollRect and hugely inspired by UI-Extensions version. I guess its my attempt at trying to fix what isn’t really broken.
The tween animations between screens is done with the free tween asset iTween which I have included in the package as it has a slight tweak which I don’t think is part of the official script from the asset store.
I invite anyone to have a go using it, I would really like some feedback on this, and if there is anything else that may be missing or could be added on to. Let me know what you think.
No problem. There have been updates I’ve made a long the way, but haven’t had time to update my repo (because im using it in a production project) and also because I use Odin serializer now and .Net 4.6 and I can’t really be bothered changing the .net4.6 stuff to .net3.5 syntax. but someday i may or ill just make the project .net4.6 only.
I’m not quite sure what you mean sorry, but if i understand you correctly, i would try using the image as a child of the main page gameobjects and have the alpha at 0, that way your child images can still be the correct ratio and the parent objects will still act as they should.
Looks like an issue with the #if defines. for some reason it’s trying to build Editor only code. I use this script (a modified version of it anyway) everyday for android/iOS so it should work. Let me get back to you ina few hours. Its about time I updated the repo anyway.
Is there a way to make this script work with a full-screen scroll view in one of the screens? Currently, we have a list of items and trying to change the screen isn’t working. Your script functions are not being triggered.
Unfortunately Unity’s SrollRect class is a little selfish and doesn’t pass its event information to its parents, BUT you can indeed have another scroller on top of the ScreenSwipe screens. You have two options:
Create your own script that extends Unity’s ScrollRect class and pass the OnDragBegin, OnDrag, and OnDragEnd events through to the ScreenSwipe script.
Use what someone has already done to a very high standard (which is what we use all the time now) called ScrollRectEx which I would highly recommend using. It is exactly the same as Unity’s ScrollRect component, but it allows the event data to be shared so you can have multiple scrollers on top of each other.