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
1
Question by keshk · Apr 13, 2015 at 01:41 AM · unity 5

UI covering my Sprite

My UI Text is displaying the number 0 as shown in the image below. It is in front of the green Square(sprite). How can I push back this UI text to go behind and let my Sprite be on top?

alt text

The text doesn't come with a sprite renderer automatically thus I tried adding one and sorting the layers and that doesn't help.

I tried sorting the layers on the top right hand corner of the inspector and doesn't help either.

a.jpg (15.6 kB)
Comment
Add comment · Show 3
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 Nerevar · Apr 13, 2015 at 08:42 AM 0
Share

If they are both UI elements, you can invert their position in the hierarchy of your canvas.

avatar image Umresh · Apr 13, 2015 at 10:08 AM 0
Share

Try changing the position of ui elements in hierarchy http://answers.unity3d.com/questions/902934/2d-ui-being-coloured-by-background-image.html

avatar image keshk · Apr 13, 2015 at 12:19 PM 0
Share

Both aren't UI elements, only the number is UI.

9 Replies

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

Answer by Priyanshu · Apr 13, 2015 at 01:02 PM

The Canvas is the area that all UI elements should be inside. The Canvas is a Game Object with a Canvas component on it, and all UI elements must be children of such a Canvas.

The Canvas has a Render Mode setting which can be used to make it render in screen space or world space.

Now if you want UI Text behind some Sprite. You need to put the render mode of Canvas (containing UI text) to World Space. Then you can put it behind Sprite.

Video tuorial: Unity 4.6 - New UI World Space Canva

Link to manual:

  1. Creating a World Space UI

  2. Canvas

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
4

Answer by Cal2 · Apr 13, 2015 at 01:11 PM

if you are using "screen space - camera" try setting the plane distance higher.

or if you are using "world space" set the axis that they are on further away.

if it is "screen space - overlay" I don't think it is possible since that is the point of overlay.

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 apple92 · Apr 13, 2015 at 11:12 AM

In General: If you work with multiple Canvas you should check out the sorting layer options: http://docs.unity3d.com/ScriptReference/Canvas.html

Within each UI Element (Canvas, Panel, etc.) nested Elements get drawn from bottom to top. So the element at the bottom gets drawn in Front, then the element above gets drawn behind and so on, until the element at the top gets drawn behind everything.

That means you would want your green sprite Image below the text in your hierarchy.

Note that changing the position of an Element will NOT change the order. Even if you position elemnts behind eachother via the Rect Transform, the Element at the bottom in the hierarchy will get drawn in front of the Rest.

For your specific need:

Okay.. It seems like you use the old GUI Components. Nevertheless...

If you want to draw the text behind the sprite, you'll need to use a TextMesh (With Mesh Renderer attached).

UNder Project Settings -> Tags and Layers -> Sorting Layers, you can create a Layer for the Text and one for the Sprite.

In the Sprite Renderer, set the right Sorting Layer. On the Text Mesh, add a Script that sets the sortingLayer on Start:

 GetComponent<Renderer>().sortingLayerName = "LayerNameOfText";


Now you just need to reorder the Sorting Layers until it fits your need.

This Should work for your case.

Comment
Add comment · Show 2 · 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 keshk · Apr 13, 2015 at 12:19 PM 0
Share

I am not using multiple canvas. In my case both aren't UI elements.

avatar image apple92 · Apr 13, 2015 at 01:18 PM 0
Share

Updated answer.

Does this work out for you?

avatar image
0

Answer by MrClottom · Apr 02, 2017 at 10:07 AM

Setting my canvas to another render mode messes everything up then all the items display way to big and distorted. Can someone explain how this solution is supposed to be practical?

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 BrunoPoupado · Jul 21, 2017 at 06:53 AM

Change Plane Distance on the Canvas untill it brings it to the front of what you want.

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

28 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

Related Questions

Unity3D in a native iOS application woes 0 Answers

Pushable head by joints or another settings 0 Answers

SystemInfo.deviceUniqueIdentifier changes value from Unity 4 to Unity 5 0 Answers

Realtime light is leaking through walls? 5 Answers

Quad does not restart position 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