- Home /
How to set up a clipping area for some but not all objects?
I'm using Sprite Manager 2 to create a puzzle game using Unity. The background images fill the entire screen, but the game board / play area fills only a part of the screen. When sprites fall into or out of this play area, they need to be clipped to the play area. The size of the clipped area is fairly arbitrary, but will be some rectangular number of pixels.
How would I go about setting up such a clipping environment in Unity? I have thought of using multiple cameras, but the Normalized Viewport Rect does not give me nearly the precision that I need. I know that with multiple cameras I could simply make one render the game board layers, and another render the backgrounds, but then it's still a matter of doing the clipping.
Ideally this would be done without any hardware-excluding shaders. In other words, ideally this will work on really old hardware. I appreciate any ideas you can provide!
I would have said "camera that renders only the sprites + normalized viewport rect"...since that offers 32-bit floating point precision, that should be more than sufficient? You can convert to screen space pixels easily enough.
I see what you're saying... yeah, that might work. Floating point precision makes me nervous in general, but I suppose that could work, yes.
Answer by Eric5h5 · Mar 19, 2010 at 04:05 AM
If you have Unity Pro, you can use GL.Viewport, which is defined by pixels, and draw sprites with GL.QUADS, although that's all done in immediate mode. However I think I should promote my comment about "camera that renders only the sprites + normalized viewport rect" to an answer, because that's what I'd use. ;)
Sounds good -- either one of those should do the trick indeed! :)
Your answer
Follow this Question
Related Questions
Polygons clipping at edge of screen 1 Answer
Camerascript works strange! 0 Answers
Camera 2d following player with delay jumps 1 Answer