- Home /
Scrolling gui texture up and down, Android
I am making some android prototypes and I need help from community for an issue. I have a long image(1280p wide and 2534p height). I want the user to scroll with finger this image up and down to read it's content. Can someone point me to some resources or solutions. Below is the image that I created to tell the storyline of the game. Sorry that I blurred it.
\
$$anonymous$$ost probably not the best solution, but have you tried just placing it in front of the camera, making sure that it looks alright, and just adjusting the camera position (or image position) when the user does the up/down motion? All you really need for that would be to know how to do the touch recognition.
Answer by robhuhn · Sep 02, 2013 at 07:47 AM
An approach would be to get the touch position in word space, calculate a velocity (previous - current) and move the camera down or a container up.
Touch touch = Input.touches[0];
touchPosition = touch.position;
touchPosition.z = -camera.transform.position.z;
touchPosition = camera.ScreenToWorldPoint(touchPosition);
...
velocityY = touchPosition.y - previousTouchPosition.y;
...
//apply velocity
newPositionY += velocityY;
camPosition.y = newPositionY;
camera.transform.position = camPosition;
previousTouchPosition = touchPosition;
I didn't test the code and some features are missing e.g. decrement the velocity when there is no touch and check for top and bottom bounds.