Author Topic: png+alpha on top of(higher depth) 2D UI  (Read 3619 times)

eco_bach

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 16
    • View Profile
png+alpha on top of(higher depth) 2D UI
« on: January 16, 2017, 09:13:42 PM »
Hi
Ngui novice. I have a 2D UI with a nested Prefab. I need to put a png with alpha on top of this nested Prefab. I've tried everything but no luck so far.
Can anyone help?

Holy Manfred

  • Jr. Member
  • **
  • Thank You
  • -Given: 1
  • -Receive: 8
  • Posts: 71
    • View Profile
Re: png+alpha on top of(higher depth) 2D UI
« Reply #1 on: January 16, 2017, 09:34:55 PM »
Should not be a problem. Maybe post your setup so we can have a look.

eco_bach

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 16
    • View Profile
Re: png+alpha on top of(higher depth) 2D UI
« Reply #2 on: January 17, 2017, 01:52:13 PM »
See the attached

My 'texture_overlay' which is a NGUI texture must appear on TOP of 'My_prefab' which is a child of the NGUI Sprite.

I've tried playing with depths but nothing seems to work.

Any help appreciated!

Holy Manfred

  • Jr. Member
  • **
  • Thank You
  • -Given: 1
  • -Receive: 8
  • Posts: 71
    • View Profile
Re: png+alpha on top of(higher depth) 2D UI
« Reply #3 on: January 17, 2017, 03:52:39 PM »
I am not sure I understand what exactly it is that is not working. I can see the UITexture in your screenshot but I am not sure about the rest.
I guess you want your texture to be rendered on top of your sprite? Without seeing the sprite/prefab settings it is hard to say.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: png+alpha on top of(higher depth) 2D UI
« Reply #4 on: January 18, 2017, 09:22:51 AM »
UI with a nested prefab? As in, you have a 3D object underneath your UI? That obviously won't work, you need to render it to texture first before it can be used by UI.

eco_bach

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 16
    • View Profile
Re: png+alpha on top of(higher depth) 2D UI
« Reply #5 on: January 18, 2017, 09:59:21 AM »
Thanks Michael. But now I am a bit confused and could use your help. Yes it is a prefab but this particular prefab(Odometer from  Asset store) requires NGUI to work.
Please see attached.

Doesn't this mean it must be nested within a NGUI 2D UI?

eco_bach

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 16
    • View Profile
Re: png+alpha on top of(higher depth) 2D UI
« Reply #6 on: January 18, 2017, 10:23:31 AM »
Or is this issue that I haven't created a proper texture or material for my NGUI Sprite.

In the attached I've created a new material containing my overlay bitmap texture. Do I instead need to create a new Atlas?

Sorry for the confusion, I haven't worked with Atlases before.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: png+alpha on top of(higher depth) 2D UI
« Reply #7 on: January 18, 2017, 11:32:45 AM »
When you specify a material like that, NGUI will create a copy of it and overwrite its MainTex with the texture coming from either UITexture (if you used that) or the sprite's altas (if you uses a UISprite).

In short, either use a UITexture + Texture2D combination, or create an actual atlas for your sprite.