Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 /
This question was closed Aug 20, 2012 at 01:25 AM by TheDarkVoid for the following reason:

The question is answered, right answer was accepted

avatar image
2
Question by TheDarkVoid · Aug 17, 2012 at 06:51 PM · gui3d

Rendering 3D objects on the GUI

What is the best way to render a 3D object/prefab on the GUI layer, or make it look like it is apart of the GUI.

Here is what i have so far:

alt text The object renders above the GUI components gameobject but not the GUI from script.

untitled.png (353.9 kB)
Comment
Add comment · Show 1
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 Mander · Aug 17, 2012 at 07:08 PM 0
Share

u could move it with u to make it look like its always there. but why owuld u want to have a 3d object on a gui layer.

3 Replies

  • Sort: 
avatar image
7
Best Answer

Answer by Bunny83 · Aug 19, 2012 at 03:22 AM

It should be no problem to render a second camera manually. Just setup your camera and disable it so it isn't rendered automatically.

In OnGUI you can do this:

 void OnGUI()
 {
     // [other GUI stuff]
     if (Event.current.type == EventType.Repaint)
     {
         objCamera.Render();
     }
 }

This would render the camera at it's setup position above the other GUI elements that are drawn in ObGUI ;)

That's one of the big advantages of the immediate-mode ;)

Comment
Add comment · Show 15 · 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 TheDarkVoid · Aug 19, 2012 at 05:28 PM 0
Share

by disable do u mean disable the gameobject or the camera component?

avatar image Bunny83 · Aug 20, 2012 at 01:58 AM 1
Share

@Ne$$anonymous$$ewSys: layers? ;)

As you can see in the screenshot above, the camera's cullingmask is set to "PreviewRender" which is one of his custom layers.

avatar image Bunny83 · Apr 30, 2013 at 07:28 AM 2
Share

@Novack: What clearflags does your second camera have? Also, do you render the camera to the full screen, or have you set the rect or pixelRect.

In OnGUI things are drawn in order, so when you draw your GUI stuff first and render a camera to the full screen afterwards it will of course overwrite the whole screen. Try it with clearflags "None" and change the rectangle the camera should render to.

I use this myself quite oftenm even on Android ;)

avatar image TheDarkVoid · Apr 30, 2013 at 10:18 AM 1
Share

you could also render depth only, witch is what i used.

avatar image Bunny83 · Apr 30, 2013 at 10:28 AM 1
Share

Yes, in most cases you will use "Depth only" or you could get in trouble with the depth buffer ;)

Show more comments
avatar image
3

Answer by Khada · Aug 17, 2012 at 08:00 PM

Create a new camera, set it to orthographic, set its depth higher/lower than you main cam (depends on your setup) and draw only the 3D GUI objects with that camera (you can use the culling mask on the cameras for this). On the camera with the higher depth value, set its clear flag to 'depth only'.

I would need much more detail to give a more specific answer.

Comment
Add comment · Show 3 · 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 Bunny83 · Aug 17, 2012 at 08:02 PM 0
Share

You're quite active! Hopefully this was the last answer i've to publish in the moderation queue ;) You should have enough karma now...

It's great to have some more active people here ;)

avatar image Khada · Aug 17, 2012 at 08:07 PM 0
Share

Haha! Sorry to make you do all that. Sadly, having my answers come late meant I missed out on a few karma opportunities which meant I still needed modding. I intend to be reasonably active. I used to do this sort of a thing a little bit over on the XNA forums. Thanks for the modding :)

avatar image TheDarkVoid · Aug 17, 2012 at 08:44 PM 0
Share

i updated the question do u have a solution to that, the depth adjustment is not working in this situation.

avatar image
3

Answer by Demigiant · Aug 17, 2012 at 07:15 PM

Best way would be to use a separate camera just for your 3D object (probably orthographic, depending on your needs), and position it relatively to the GUI.

Else, but I'm not sure if it's really doable, if you have Unity Pro you could still use a separate cam only for your object, render it to texture, and place that texture somewhere in your GUI.

Comment
Add comment · Show 7 · 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 TheDarkVoid · Aug 17, 2012 at 07:36 PM 0
Share

i was thinking of having a camera for the object but i was wondering if there was an easier way. i dont hav pro, but i plan to get it.

avatar image TheDarkVoid · Aug 17, 2012 at 08:11 PM 0
Share

but the problem is how i get this to render above the GUI layer

avatar image Khada · Aug 17, 2012 at 08:16 PM 0
Share

That's what a cameras 'Depth' controls, it's draw order. You may need to add more than one camera to get the desired effect (think of each camera as a layer).

avatar image TheDarkVoid · Aug 17, 2012 at 08:31 PM 0
Share

i tried adjusting the depth, but it never got infont of the GUI, i also tried removing the GUIlayer component from the camera. i added a pic to the question.

avatar image TheDarkVoid · Aug 17, 2012 at 08:47 PM 1
Share

that's too bad, i dont hav pro, so i'll probably just render a still image to use until i get pro.

Show more comments

Follow this Question

Answers Answers and Comments

13 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

Related Questions

2D Arrow pointing at 3D Position 1 Answer

Drawing GUI Text using Javascript 2 Answers

3D ^ Custom GUIText/Label or Making a Score System without using GUI? 0 Answers

3D object in uGUI 3 Answers

3D Object in GUI 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