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 violgamba · Aug 22, 2020 at 07:30 PM · canvasaspect-ratioorder

Canvas draw order messed up on render mode change (overlay to camera)

I'm retrofitting a completed game to work on mobile and in order to support different aspect ratios (through letterboxing) I've changed the canvas from "Screen space - overlay" to "Screen space - camera". The issue is this: before the change the ui elements were drawn in nested heirarchy order from top to bottom. After the change, I don't really know what the draw order is, but it's definitely not top to bottom.

Is there a way to change the canvas to "Screen space - camera" without losing the heirarchy-based draw order and without needing to set z position for each ui element? (it's quite a complex ui).

Alternately, is there a way to change the render position/size of "Screen space - overlay" on the screen to allow letterboxing?

Thanks for any help you can provide.

EDIT: I just tried to recreate the issue with a simplistic new Unity project and the nested heirarchy ordering remained when switching render modes. The question now becomes: what would cause the non-heirarchy-based ordering of ui elements in the main project? The z position is 0 for all of the ui elements...

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 violgamba · Aug 22, 2020 at 09:50 PM

I've worked through to an answer to this question. It actually had multiple answers, which I've provided below.

1) This first issue wasn't a draw order thing as it turned out. It was that canvas elements in "overlay" mode measure space in pixels, while elements in "camera" mode measure space in camera-specific coordinates. If a custom cursor is placed at the mouses (pixel) position each frame, it shows up fine in "overlay" mode, but in "camera" mode it requires transforming the mouse pixel coordinates to camera coordinates first.

2) This second issue was tricker: Some of the canvas ui elements use custom shaders. These shaders worked fine when the canvas was in "overlay" mode, but switching the canvas to "camera" mode caused some of the shaders to draw out of order. The solution (for me) was to add the "Queue" tag to the out-of-order shaders. This tag helps define the order of rendering. The bad shaders were missing this tag so were defaulting to the "Geometry" Queue. This was fine in "overlay" mode, but in "camera" mode the "Geometry" queue is rendered before elements with the default ui shader (UI/Default).

Fixing these two issues resolved my woes. I hope they can help someone else struggling through this process.

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

140 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

Related Questions

Ordering UI elements in the Hierarchy is affected by DontDestroyOnLoad 1 Answer

How to see what the UI canvas will look like in the final build? 0 Answers

Canvas - Aspect ratio fitter 0 Answers

Issues with world space canvas for different resolutions. Any Workaround ? 0 Answers

How to make my UI items/canvas stretch to fill preset aspect ratio 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