Author Topic: Where to start creating a custom mask / filled sprite  (Read 6995 times)

kevork

  • Guest
Where to start creating a custom mask / filled sprite
« on: June 17, 2013, 01:32:56 PM »
If one wanted to have a mask (filled sprite) over another image, where based on where the user touched the mask is set transparent revealing the image underneath (think lotto ticket or fog of war), what would be the best place to start with NGUI?

Thanks!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Where to start creating a custom mask / filled sprite
« Reply #1 on: June 17, 2013, 09:46:37 PM »
Just one sprite on top of another, change the alpha of the top sprite from 1 to 0?

kevork

  • Guest
Re: Where to start creating a custom mask / filled sprite
« Reply #2 on: June 18, 2013, 01:18:09 AM »
I want the revealed area to represent whatever input the user has recently entered, i.e. the user could remove the top half or the bottom half or make stripes, etc.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Where to start creating a custom mask / filled sprite
« Reply #3 on: June 18, 2013, 10:27:33 AM »
Create a Texture2D and fill its content dynamically, then use UITexture to draw it on top of another sprite, effectively covering it.

kevork

  • Guest
Re: Where to start creating a custom mask / filled sprite
« Reply #4 on: June 18, 2013, 11:15:35 AM »
Thanks as always ArenMook.

kaplovskivisuals

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: Where to start creating a custom mask / filled sprite
« Reply #5 on: March 25, 2014, 05:50:18 AM »
Hey, my question is a similar one. I am an artist however and a little new to NGUI. I have a label that I want to be able to partially hide from view, like the fill parameter in sprites. I think this is done with a separate sprite on top of the label that hides only the label text but still shows all other sprites and labels around it.

How do I create a mask-only sprite in ngui and how do i connect it exclusively to one label?

Thanks in advance

kaplovskivisuals

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: Where to start creating a custom mask / filled sprite
« Reply #6 on: March 25, 2014, 06:04:38 AM »
also, i cannot put this transparent texture in the atlas, thus creating multiple draw orders which i don't want.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Where to start creating a custom mask / filled sprite
« Reply #7 on: March 26, 2014, 02:14:47 AM »
So... you want to mask out a part of the text, but you want to do it without causing extra draw calls?

The only way to do that is to create a custom label class that will clip the text. I can't be of much help here as this would be highly custom and rather advanced functionality in terms of difficulty.