Author Topic: Problem with non-square progressbar (we can not use "filled")  (Read 2957 times)

artfabrique

  • Newbie
  • *
  • Thank You
  • -Given: 5
  • -Receive: 0
  • Posts: 45
    • View Profile
Problem with non-square progressbar (we can not use "filled")
« on: September 23, 2015, 10:00:26 AM »
Good day!
Can you tell us the approach to do this type of progress bar? (notice state 0 and 1)


We can not use filled texture, because we want non-square fill tip while progress.
We have one big ui atlas (2k x 2k) with all the elements.
This atlas has a material/shader etc.
We think the right way is to mask progressbar fill somehow but it seems that we can't because all UI sprites is inside single atlas (single mat, single shader). And if we will have shader with mask support for that atlas it will mask all other elements besides progressbar fill.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Problem with non-square progressbar (we can not use "filled")
« Reply #1 on: September 26, 2015, 04:28:55 PM »
NGUI works with square sprites, so if you want something cut at an angle like that your best bet is to create a custom widget. Simply derive from UISprite and write your own custom OnFill function that will make it slanted the way you want.

artfabrique

  • Newbie
  • *
  • Thank You
  • -Given: 5
  • -Receive: 0
  • Posts: 45
    • View Profile
Re: Problem with non-square progressbar (we can not use "filled")
« Reply #2 on: September 28, 2015, 11:58:55 AM »
NGUI works with square sprites, so if you want something cut at an angle like that your best bet is to create a custom widget. Simply derive from UISprite and write your own custom OnFill function that will make it slanted the way you want.
We don't want to cut sprite with geometry, because we have non uniform tip.
As you see we have a mask there but dont get what is the right strategy.
What if we have this shape?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Problem with non-square progressbar (we can not use "filled")
« Reply #3 on: September 28, 2015, 01:16:59 PM »
Sliced sprice corners / sides don't get stretched or cut. They get drawn as-is. In your case you want the side sprite parts to actually get cut. NGUI doesn't offer something like that, so again -- create a custom OnFill function. No masks needed. It's much more difficult to get this done with masks, and you'll be adding an extra draw call for no reason.