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
2
Question by Cyclops · Mar 18, 2010 at 08:00 PM · cameraguilayers

How to move GUI objects to separate Camera Layer - and why?

I read the suggestion (somewhere) that the GUI elements should be on their own layer, with their own camera, separate from the game layer. Unfortunately, I can't find the post again. :) So I have two question about that.

First, why? What are the consequences of having the GUI on a separate layer? Assume that I write reasonably modular code, and all my GUI display elements are in one script (and they only set State variables that other scripts use).

Second, (and I hate to ask this :) but how? I have followed every step in the Unity Layers Guide. I have created a new Layer called GUI, and assigned my GUI_gameobject (called GuiTop) to that layer. Then I unchecked GUI on the main (only) Scene Camera Culling Mask. At this point, I am presuming that my GUI buttons would not be visible, since the only existing Camera is not supposed to display that layer. Yet they display...

The GuiTop is an empty GO that has a script attached - this script has the usual OnGUI() and GUI.Button() type statements. Is it sufficient for GuiTop to be assigned to the Layer GUI, or do I need to also do the script component?

Or is there some other step I'm missing?

Ah, I also removed the GUILayer component from the Camera, although as far as I can tell, this is only for GUITextures, shouldn't have an effect - and didn't.

Comment
Add comment
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

1 Reply

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

Answer by Eric5h5 · Mar 18, 2010 at 08:07 PM

1) I have no idea...toggling the GUILayer component will turn on and off all GUIElements anyway.

2) OnGUI is different from GUIElements, does not use the GUILayer camera component, and cannot be put on a separate layer. It's always drawn on top of everything.

Comment
Add comment · Show 5 · 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 Cyclops · Mar 18, 2010 at 08:46 PM 0
Share

So they're two totally different systems? Well, that explains things. And looking at the main Unity Game Elements page, they sort of mention that, but it's definitely not made clear.

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

@Cyclops: Yep, two totally different systems.

avatar image Cyclops · Mar 18, 2010 at 09:04 PM 0
Share

@Eric5h5, thanks. Though that brings up performance questions, now :) which I suppose should be in a separate question.

avatar image coffiarts · Jun 03, 2013 at 10:14 AM 0
Share

Do I understand it in the right way that we still do not know why one should use a dedicated camera for the GUI?

Because I am having the same difficulties as Cyclops of understanding that concept/recommendation.

avatar image Kale · Jun 25, 2013 at 07:03 PM 0
Share

Wild guess here, and I'm almost certain it's not the "best" answer.

$$anonymous$$aybe it has to do with Field of View and controlling GUI settings. If you have a first person shooter, and wish to allow the player to have the ability to change the field of view; you can safely do so without the GUI beco$$anonymous$$g too big or small because of it. On the other hand, you can re-size the GUI without affecting the game's settings.

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

2 People are following this question.

avatar image avatar image

Related Questions

Is there a way to change the order of the "Layers" Tab? 0 Answers

Stop rendering scene when GUI window is active. 2 Answers

Rendering a camera in front of a gui element 3 Answers

GUI to follow 3d instantiated object in other camera? 1 Answer

LineRenderer with moving 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