Author Topic: UILabels always on top of UITexture  (Read 3333 times)

flavoredCoffee

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 15
    • View Profile
    • CWGTech Unity & Programming blog
UILabels always on top of UITexture
« on: September 11, 2013, 06:00:41 PM »
I'm trying to create a fade out/in overlay when I switch levels.  I'm creating a UITexture object in a script and giving it a black texture with alpha 0, and then fade to alpha 1.  The UITexture object has it's depth value set to 100 and it's Z position to just before the camera Z.

As I expected, the texture covers everything on the screen, except the UILabels.  (FYI - dynamic font in case it matters).

The UITexture is not using the atlas.  The UITexture has a lower Z value than any of the labels.  It has a higher depth.  It's been in its own panel, or the same panel as the labels - makes no difference.  I guess I could add another 2D camera and have it on top of everything, but I'd rather not do that unless it's the only option.

The UITexture will cover up a button's background image, but the label is drawn after the texture.  Any other ideas on how to correct this?

Thanks

FC

Wumpee

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 53
    • View Profile
Re: UILabels always on top of UITexture
« Reply #1 on: September 11, 2013, 07:30:48 PM »
Adding a separate camera isn't a bad option. There's no extra overhead as long as you have the clear flags set to "Don't Clear"

You could also try adjusting the Z depth of the panel you've attached the overlay to, rather than changing the Z depth of the UITexture overlay itself.
« Last Edit: September 11, 2013, 08:32:19 PM by Wumpee »

flavoredCoffee

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 15
    • View Profile
    • CWGTech Unity & Programming blog
Re: UILabels always on top of UITexture
« Reply #2 on: September 11, 2013, 11:56:36 PM »
Ok -- I'll look into adding another camera -- I tried adjusting all the different Z options on each item with no luck.

I'll let you know how I get on.

FC

nugao

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 14
    • View Profile
Re: UILabels always on top of UITexture
« Reply #3 on: September 12, 2013, 12:42:32 AM »
Just change UITexture's shader from 'Unlit - Diffuse' to 'Unlit - Transparent Colored'.

Because the Transparent object always in front of the Opaque object, in other words the Opaque objects always render in front of the Transparent object in render queue.

flavoredCoffee

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 15
    • View Profile
    • CWGTech Unity & Programming blog
Re: UILabels always on top of UITexture
« Reply #4 on: September 12, 2013, 09:31:55 AM »
Thanks!

That did the trick.

FC