Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
0
Question by xhonzi · Apr 07, 2014 at 05:55 AM · cameratextureplane

GUI on one camera visible to other camera

I'll try to make this as simple as possible. I have two cameras and I want to attach a 2D GUI to one of them, but see the GUI on the other. It's a gun with its own HUD, but the player camera can see it.

I'm new to Unity- I tried mounting a plane to the gun, amd then texturing the plane- but the plane only takes materials (any way to 'texture' a plane?) and it was affected by lighting. I want to draw 2D texture/GUI elements, so I thought maybe I should be using a GUI layer. But I believe these are invisible to other cameras- right?

Any ideas?

Thanks!

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
0
Best Answer

Answer by supernat · Apr 07, 2014 at 06:20 AM

First I'll answer the plane question. Materials can contain textures if their assigned shaders support textures. Most materials (but not all) use textures. If you click on a game object in the editor, select the material, you should see a texture there if it's one of the commonly used ones like Diffuse, Specular, etc. You can set the texture of the plane at runtime by assigning a Texture2D (most likely) to it, but that requires that you have said texture to assign, which in your case sounds like something that would be dynamically changing while playing. If that's the case, then you would have to Render to Texture (A Unity Pro only feature). But lucky for you, you don't need or want that. It's way too excessive. However, for future reference, you can access the texture (most of the time) with mainTexture from the material. See: http://docs.unity3d.com/Documentation/ScriptReference/Material-mainTexture.html.

Cameras in Unity are a bit more complex than just "Render something to this area from these layers". They are ordered and cumulative. They are ordered based on the Depth value you set in the Inspector for a camera. Unity will render 1 first and then the next. If the 1st camera clears the depth and color buffers (another option in the inspector for a camera), and the 2nd camera clears just the depth buffer, you end up doing something like this:

Camera A renders the full scene for whatever layers you have selected in the Cull mask.

Camera B clears the depth buffer (basically allows camera B to render everything on top of what's already in the color buffer).

Camera B renders whatever layer is selected in the Cull mask.

So, this is a common technique to render UI in its own layer that is applied after the world is rendered by the 1st camera. So far, so good. If you just wanted to render the UI in the same place on the screen all the time, you could set camera B at the origin of the world, then make the UI components children of camera B, and even if you moved camera B, the UI would always be in the same relative places on the screen, regardless of where camera A is.

You want your UI to move though. I haven't tried this specifically, but using the information above, you should be able to child camera B to camera A if the gun HUD remains fairly constant in the world while your camera looks around (i.e. the HUD doesn't move with camera A). The other key is to child the UI components to the gun's HUD, and then camera B should always be rendering the UI in the proper place. With those two things, it seems like it would work.

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

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

22 People are following this question.

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

Related Questions

Make a plane show the cameras "fov" 0 Answers

copying a 2d/3d plane/slab from one part of world and displaying it in another? 0 Answers

360 degree plane rotation & texture change 1 Answer

Trees in distance show as black without texture 1 Answer

Camera starts shaking after 2 minutes of continuous flying! 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