• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by x4000 · Mar 18, 2010 at 07:47 PM · camera2dclipping

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!

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Eric5h5 · Mar 18, 2010 at 07:54 PM 0
Share

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.

avatar image x4000 · Mar 18, 2010 at 08:18 PM 0
Share

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.

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

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. ;)

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image x4000 · Mar 19, 2010 at 03:12 PM 0
Share

Sounds good -- either one of those should do the trick indeed! :)

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Polygons clipping at edge of screen 1 Answer

Cinemachine weird lines of color when moving? 1 Answer

How do I get rid of this motion blur? 0 Answers

2D Orthographic Camera Help 0 Answers

Camera.ScreenToWorldPoint with Perspective camera 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges