Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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
1
Question by M_Hoepp · Sep 14, 2016 at 02:14 AM · renderinglayerscamerasculling maskmultiple cameras

Make GameObjects dynamically visible/invisible for certain cameras

I have multiple cameras (no static amount, new cameras can be created, but usually it should be less than 20), and have certain GameObjects (no fixed amount, could be 10, could be 40), I'll just call them "Toggleable GOs" here. I want to be able to make them invisible and visible dynamically (at runtime) for a certain camera without turning them visible/invisible for all cameras.

Obviously Culling Masks and Layers should come in handy, but they don't, here's the Plot Twist: You can only assign one layer to a Game Object. I can't make a game object visible on multiple layers. So I can't just have cameras that render only the default layer plus a specific layer assigned to them and then modify the Layer Mask of the "Toggleable GOs" every time I want to make them (in)visible, because in Unity there's no Layer Mask for GOs, there's only a single Layer property. Doing it the other way around (assigning "Toggleable GOs" to specific layers, and modifying the culling masks of the cams) doesn't work because of the layer limit. Keep in mind I might have more than 32 "Toggleable GOs".

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 DavidWatts · Sep 14, 2016 at 02:49 AM 0
Share

maybe you could use Draw$$anonymous$$esh and draw the meshFilters shared$$anonymous$$esh. https://docs.unity3d.com/ScriptReference/Graphics.Draw$$anonymous$$esh.html

avatar image Namey5 · Sep 14, 2016 at 02:57 AM 0
Share

You could use replacement shaders on your cameras, and simply have a shader that doesn't render.

https://docs.unity3d.com/$$anonymous$$anual/SL-ShaderReplacement.html

1 Reply

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

Answer by YinXiaozhou · Sep 14, 2016 at 09:35 AM

Then just turning them visible/invisile for each camera. https://docs.unity3d.com/ScriptReference/Camera.OnPreRender.html

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 M_Hoepp · Sep 14, 2016 at 08:48 PM 0
Share

Thank you, that was exactly what I needed. It also has no mesurable effect on my framerate; Performance is still excellent, and I'm not even limited by the layer count. Btw OnPreRender actually was not working exactly as I expected, I needed OnPreCull in order for it to run correctly.

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.

Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Same flare appearing in two diferent cameras 0 Answers

SplitScreen shooter with Viewmodels and PlayerModels without so many layers? 1 Answer

Unity - blur on one camera effects the other as well 0 Answers

How to save multiple camera views into different video files? 0 Answers

materials visible if seen by (1) all or (2) any camera(s) 0 Answers


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