Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 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 /
  • Help Room /
avatar image
1
Question by RoofTurkey · Sep 12, 2016 at 08:07 AM · uirenderingorder

UI stays behind game objects

Hi!

Currently I have a problem with my UI. Due to some warping that is being done with the camera (to fit the rendering nicely onto a projector while remaining 16:10) I have to use the "Screen Space - Camera" option on my UI. This has however caused the UI to stay behind my game objects. This can be seen on this image for example: alt text The settings on the UI are as follows:

  • The main camera is set to the correct camera

  • The plane distance is set to 0.31, the cameras near clipping plane is set to 0.3

  • Sorting layer is set to 'Default'

  • Order in layer is set to '0'

  • Rect Transform scale is set to 0.0002443...

I've tried many different things and the only thing that worked so far was changing the rendering mode from 'Forward' to 'Deferred', but this caused a whole lot of game objects to be rendered bad.

Does anyone know how I might be able to solve this issue?

dsc-0002.jpg (6.4 kB)
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

6 Replies

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

Answer by troien · Sep 12, 2016 at 09:24 AM

If you really have to use screen space camera instead of screen space overlay and your camera is that close to objects that the UI will clip through. I think you don't have that many options...

These are the ones I can think of:

  1. Set the plane distance as low as possible (Think you already did that)

  2. Make sure the UI component don't have their z position set (to anything above 0, as this will move them further away from the camera, higher chance they will clip through the objects you are looking at)

  3. ignore point 1 and 2 and use another camera used only for the UI You can make this new camera a child of your existing main camera for instance. Make sure its culling mask is set to UI, your other cameras ignore UI and then play with the depth of your new camera (Make sure its value is higher then the depth of your main camera) And ofcourse make sure you set this camera as render target of your canvas. Also, set the new camera clear flags to depth only :p

I believe setting the sorting layer and order in layer has no effect as these values are ignored by 3D objects. If you are not using 3D gameobjects but 2D ones instead (Sprite Renderer instead of Mesh Renderer), they should work I believe ;)

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 RoofTurkey · Sep 12, 2016 at 09:35 AM 0
Share

The problem also occurs with objects that are far away from the camera, the distance doesn't seem to make any difference at all. Point 1 and 2 don't solve the issue and point 3 will probably solve it, but this causes some other issues and I would therefore like to find a solution where adding another camera isn't necessary.

avatar image troien RoofTurkey · Sep 12, 2016 at 09:45 AM 0
Share

"The problem also occurs with objects that are far away from the camera"

What do you mean by this? Perhaps an image of your scene view can clarify this :p

But that object that is behind the UI and gets rendered in front,

  • Does it use a shader that could cause it to be rendered in front? :p

  • Does it get rendered by the same camera as the UI or by a different one (with a higher depth value)?

avatar image RoofTurkey troien · Sep 12, 2016 at 09:50 AM 0
Share

"Does it get rendered by the same camera as the UI or by a different one (with a higher depth value)?"

That was it! There was a different camera rendering objects in front of the UI. I've now set that depth lower and the UI is on top as it should :) . Thank you very much.

avatar image
11

Answer by rajan4uto · Sep 12, 2016 at 09:30 AM

if you are using "Screen Space - Camera" in canvas then decrease the value of "Plane Distance" in canvas.

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 devondyer · Dec 28, 2017 at 08:25 PM 1
Share

This would be the most efficient answer to the problem

avatar image
3

Answer by Dream_in_code · Sep 12, 2016 at 08:33 AM

Did you trt ordering the layer of the gameobject?alt text Try setting the value to negative.


screenshot-1.jpg (29.7 kB)
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 RoofTurkey · Sep 12, 2016 at 08:41 AM 1
Share

Changing the 'Order in Layer' did not change anything, not even when I set it to extreme values.

avatar image
0

Answer by PraetorBlue · May 02, 2020 at 05:47 PM

Adding a new sorting layer and adding my Canvas to it did the trick for me.

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

Answer by aligonabadi · Sep 24, 2020 at 12:22 PM

I had same Problem. Increasing Depth in camera settings, fixed my issue.

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
  • 1
  • 2
  • ›

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

84 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

Related Questions

Why does my font stop rendering after some builds? 0 Answers

iOS build not rendering properly 1 Answer

Mixing sprite renderer and mesh renderer sorting layers 1 Answer

Draw a time line ingame with a lot of lines? (New Ui, no GL.lines) 0 Answers

How to change drawing order in Unity? 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