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
2
Question by Tezemi · Apr 16, 2015 at 08:58 PM · guibugcanvasguitextbehind

Unity 5.0.1, GUI text always displays behind game objects

Just updated to the newest version on Unity. I've just started working on a 2D project. I've been trying to add some GUI text but it always displays behind the game objects. After adding the new GUI text and it creates the canvas component, I was under the impression that the canvas component was supposed to fit to the size of the screen, but instead it does this: http://puu.sh/hgfuv/f9008cb028.png The canvas is massive and so is the GUI text compared to the camera. I selected the 'Screen Space - Camera' for the render mode, which fits the canvas to the camera and makes the GUI text about the right size, the only problem is that the GUI text always appears behind game objects, like this: http://puu.sh/hgfKo/7e5f9877f6.jpg I really hope this isn't a bug and it's just me not understanding the new Unity GUI system very well. Any solutions?

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 KokodokoGames · Aug 29, 2015 at 01:05 PM 0
Share

Same problem here, it's highly annoying to keep zoo$$anonymous$$g in and out if you switch between scenes. Setting the canvas to a normal size renders it behind gameobjects, even if you set the Z value closer to the camera. So apparently the canvas has to be HUGE which is confusing when you like to work with exact pixel values - something you always do in a 2D game.

It's all very inconvenient and clumsy, you really start to wonder what the Unity devs were thinking when they implemented this system.

We can only hope that Unity 6 will fix all the 2D issues, the list goes on and on.

4 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by YoungDeveloper · Apr 16, 2015 at 09:21 PM

  • For always on top drawing use Screen space - overlay, and yes, it's huge and you should not worry about it. This is the closest alternative to old OnGUI() and will be drawn always on top.

  • If you want the elements to have depth - draw in layers, behind gameobjects or whatever use "Screen space - camera". If you select it Render Camera field will appear, which you must assign with your main camera. You will see that it also auto scales just like Screen space - overlay and rotates correctly with camera.

  • World space is in free world space, just like any scene gameobject.

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 Tezemi · Apr 17, 2015 at 12:51 AM 0
Share

Alright, is there anyway to shrink the size of the GUI text? It's massive and decreasing the font size just creates weird, blurry, almost unreadable text.

avatar image YoungDeveloper · Apr 17, 2015 at 12:56 AM 0
Share

If you want small text to be extremely readable, i found one way that works. For Text component, set the scale to (for example) (0.3 0.3 0.3) and increase font size. Here's a setup i tried in seconds. alt text

avatar image KokodokoGames · Aug 29, 2015 at 01:06 PM 1
Share

But if you select 'screen space - camera' the GUI appears BEHIND all game objects. Regardless of Z settings.

avatar image
0

Answer by prateekpy-21 · Jul 23, 2015 at 12:21 AM

If u really want to add guitext do it by adding UItext just follow these steps: 1. In Hierarchy Creat-> UI-> Text. 2. Now set anchor texts others as per your requirement. 3. In script if u want to access it (C#) code then use using UnityEngine.UI; 4. Then create public GameObject guitext. 5. In inspector left click on the UIText->Canvas and select the child Text field and drop on inspector gameobject variable guitext. 6. Now in script access the text as: guitext.GetComponent().text 7. NOTE : Remember to add using UnityEngine.UI else error will occur. Also when moving object from hierarchy only Text should be moved else again error.

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 starrtennis · Feb 01, 2019 at 06:32 AM

Make the Sorting Layer of your Canvas in front of the Sorting Layer of your game objects.

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 Lord_Dov_Sabol · Sep 15, 2020 at 03:46 AM

I found a way that does not require any scripts (although i am not sure about what this will change or what the consequences are), if you go onto your canvas, and on the canvas component, change the "Plane Distance" from 100 to something like 10, it should be normal.

Hope this helps!

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

7 People are following this question.

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

Related Questions

Canvas wired rotation bug 1 Answer

Canvas Text gets garbled 0 Answers

GUI co-ordinates bug? 1 Answer

GUI Problem 1 Answer

Use Unity UI For 2D Games Or Custom Objects Instead? 2 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