• 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
Question by austinbrianrogers · Jan 31, 2020 at 10:23 PM · ui3drenderingcanvas

3D Objects on a UI canvas with LWRP?

Hi everyone,

I'm currently developing UI on a project and have encountered a bit of a snag in one of my current problems.


I'm intending to put 3D objects onto a canvas such that that are part of the UI. I investigated camera stacking a bit, but have learned that camera stacking isn't yet supported with LWRP. You can read more about that here: https://forum.unity.com/threads/glitching-with-multiple-cameras-lwrp.592477/


My current situation is this:


I have a screen overlay canvas for all UI elements. I have a prefab piece of UI that is dynamically added to the canvas as needed. Part of this prefab is a 3D model that is supposed to represent objects that the player character picks up. The model needs to be part of the UI prefab to preserve its position and sit alongside text and numerical information over the player character, like the amount of currency the player has picked up off the ground at some moment. So, I have 2D and 3D elements taking up canvas space as part of the same prefab.


I have tried separating the canvas into two unique canvases. The second [new] canvas was a camera overlay. Then, I created a second camera specifically to attach to this new canvas. I was intending on using the Clear Flags on this camera so that the 3D UI could sit over the other camera's render, but due to the previously mentioned issue with LWRP, Clear Flags are not supported as far as I know.


With my current set up - one canvas, one camera - I can see all of the 2D elements on the canvas, but none of the 3D elements. The 3D and 2D elements are part of the same object / prefab on the canvas, but I can only see the 2D parts of it in the game view. It is also worth noting that the 3D object is visible as intended in the scene view, but not the game view.


Has anyone attempted to solve a similar problem using LWRP? I would really appreciate some insight on drawing 3D objects on a canvas. More curiously, I would like to know why they are visible on the canvas in the scene view, but hidden in the game view.

Comment
mario83

People who like this

1 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 mario83 · Jun 08, 2020 at 07:56 AM 0
Share

hey, austin. Have you figured out a way to do this? I want to do something very similar and ran into the exact same situation you described here (with URP). 2D stuff is visible, when I pause I see the 3D objects where I would expect them, but in game, they are not visible.

Would be super helpful, if you found a way to do this.

2 Replies

· Add your reply
  • Sort: 
avatar image

Answer by kromenak · Jan 31, 2020 at 10:35 PM

I believe a canvas in "Screen Space - Overlay" mode will draw all its UI elements after objects in the scene and on top of any scene objects.

Even though you have 3D objects as part of the UI prefab, those 3D objects will NOT be drawn at the same time as the UI elements. I think what would happen is the 3D object would get drawn during scene rendering (per the properties of its material/shader) and the UI elements in the "Screen Space - Overlay" canvas would be drawn last and on top of everything, potentially obscuring your 3D object.

One suggestion I'd have is to try using "Screen Space - Camera" mode instead. This actually puts the UI canvas in your 3D world, some distance in front of a particular camera. In my testing, this then allows 3D objects to properly render in front of or behind the UI - you can just imagine that your UI and 3D model all exist as objects in front of the camera, which is exactly how you expect a camera to work in the real world.

You might run into some issues if you have overridden any settings that affect draw order of objects in the scene - for example, culling mask, camera depth, layers, canvas "sorting layer" and "order in layer", material render queue values, etc. But absent all of those complicating factors, I think this works correctly - at least, when I do a simple test in a scene with a single camera, screen space-camera canvas, a UI image, and a 3D cube, it seems to work fine.

Comment
mario83

People who like this

1 Show 0 · 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

Answer by Tarodev · May 04, 2021 at 12:59 AM

Here's a quick (2m) tutorial: https://www.youtube.com/watch?v=8yzpjkoE0YA

Comment

People who like this

0 Show 0 · 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.

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

247 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 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 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 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 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 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 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 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 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 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 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 avatar image avatar image avatar image avatar image avatar image

Related Questions

Optimizing Performance in Scenes with Moving Canvasses 0 Answers

How do Image shaders interact with UI Canvas draw order? 0 Answers

Raw image not visible in overlay canvas 0 Answers

Canvas items turned to be blank images 0 Answers

LineRender width not consistent across resolutions 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