- Home /
What's the best way to do pinch zoom?
Currently I'm using 2dtoolkit for my project and I wanted to implement pinch zoom.
My initial idea is to have a RootNode, then set everything other sprites under this RootNode, so that when I do pinch zoom I just need to scale the RootNode accordingly.
But later on I realised, most of the tutorials/suggestions I found online are modifying the camera instead of scaling. I wanted to ask which is the better way to implement pinch zoom?
If I use camera to do zooming, what about those UI objects? Since camera will just zoom everything on the scene, how can I set it to make sure zoom the game objects only but not UI objects? How should I setup a second camera to handle this?
Assu$$anonymous$$g you've already realized how much OnGUI sucks and are using ordinary GameObjects for your UI- you shouldn't be rendering them with the same camera you use for your scene anyway. You want an orthographic camera that only renders the "GUIStuff" layer that is a higher layer than all the others set to clear Depth Only, and your main camera that renders everything but the "GUIStuff" layer on a lower layer.
I try to add a second camera but when I run, it only show one camera, how can I make it to have both camera rendered on the same scene? is there any tutorials about this?
Answer by Owen-Reynolds · Feb 24, 2014 at 04:44 PM
Growing the scene won't work well with physics (gravity and speeds will be wrong,) particle systems (they ignore local scale) and Terrain (same.) Probably some more stuff (like non-physics movement code.)
If the UI is using Unity GUI elements, moving the camera for a 3D zoom will have no effect ((0, 0.5) is always center left-side.) And, if you have to, a 2nd camera is cheap (it's hard not to think about how expensive a real 2nd camera is. But a computer camera is only a handful of variables.)
So do you mean even for screen panning, I should be moving the camera ins$$anonymous$$d of the game objects?
Well, physics and Terrain don't care if you move them. But particle systems could still break. Setting to local space make particles move when the emitter moves. But it you have a moving one (like a ball trailing smoke,) don't think there's a good way to move them all together (if you check LocalSpace, the smoke sticks to the ball as it moves.)
Your answer
Follow this Question
Related Questions
Keeping 2D orthographic camera with zoom in level boundaries 0 Answers
Hello I'm trying to write a C# about "Pinch to zoom" but it doesn't work 1 Answer
2D Animation does not start 1 Answer
Zoom to center of Pinch Gesture 1 Answer
[UI] proper way to add pinch zoom only to one UI element on the screen? 0 Answers