1
\$\begingroup\$

I'm trying to add some text to my Canvas but it seems to disappear in front of it? So does particle systems and other things?

It is a child object of the canvas.

enter image description here

\$\endgroup\$
5
  • \$\begingroup\$ Try adding another Canvas component to the child object, and then Override Sorting. \$\endgroup\$
    – jgallant
    Commented Aug 25, 2016 at 12:37
  • \$\begingroup\$ Okay that worked. If you put it as an answer I can select it. Would prefer an explanation as to why it worked though in the answer too if you can. \$\endgroup\$ Commented Aug 25, 2016 at 12:41
  • 1
    \$\begingroup\$ It looks like your "DevBy" text is sitting before the background "Image" in the hierarchy list. By default, things render in the order of the hierarchy list, so your image may be rendering over your text. If you drag DevBy so it sits below Image, does that solve the problem without adding a new Canvas? \$\endgroup\$
    – DMGregory
    Commented Aug 25, 2016 at 12:54
  • \$\begingroup\$ Oh, that may be it. A quick question if you guys don't mind: I'm actually building my game now and it's going through ALL the files that I have downloaded (I downloaded a big skybox pack that contains several skyboxes but I obviously only use 1). Do I need to remove everything in my project folder that I didn't explicitly use in my game or else it will be built with the game? \$\endgroup\$ Commented Aug 25, 2016 at 13:02
  • \$\begingroup\$ You can post that as a new question. ;) The short answer is that Unity will only include assets referenced within one of the built scenes OR inside a folder named "Resources" - so if you keep unused assets out of that folder then they should be omitted from the build. \$\endgroup\$
    – DMGregory
    Commented Aug 25, 2016 at 17:45

2 Answers 2

1
\$\begingroup\$

Try adding another Canvas component to the child object, and then Override Sorting:

enter image description here

If you rely on the default sorting order, it will use the same as the Canvas parent. This can cause issues with z-order fighting.

\$\endgroup\$
0
\$\begingroup\$

The children of a canvas are rendered in order. So it first renders the text, then overdraws the text with the image, then overdraws part of the image with the button. If you want the text to appear above the canvas, then drag the "DevBy" game object below the "Image" game object in the scene hierarchy.

So does particle systems and other things?

If you want the image to be the background image of not just your user interface but of the whole game, then it shouldn't be part of the user interface canvas. A common method is to place it as a Plane or Sprite in 3d space.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .