Author Topic: suggestion: inverted SlicedSprite  (Read 7604 times)

Gillissie

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 48
    • View Profile
suggestion: inverted SlicedSprite
« on: December 03, 2012, 03:45:38 PM »
I would love it if I could slice a sprite and scale it so the center stays actual size and the edges stretch, which is the opposite of what Sliced Sprite does right now. What I need to do is have a sprite with a huge amount of edge color around it (repeating the edge pixel), but I don't want to (or can't) make an atlas large enough for that kind of sprite.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: suggestion: inverted SlicedSprite
« Reply #1 on: December 04, 2012, 02:47:55 AM »
I... am not even sure what this would be used for, to be honest. That said though, you're welcome to create your custom widget based on the sliced sprite's code. It's openly available for a reason. ;)

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
Re: suggestion: inverted SlicedSprite
« Reply #2 on: December 04, 2012, 08:55:45 AM »
Hi Gillissie, I'm also interested to see what it can be used for.

Can you provide an example?

Gillissie

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 48
    • View Profile
Re: suggestion: inverted SlicedSprite
« Reply #3 on: December 04, 2012, 01:55:11 PM »
In my particular case, I want to use it as a way to highlight things in the UI. I created a texture that is black with a soft hole in the center. I position the sprite where I want to highlight something (imagine a tutorial pointing out certain features), with partial transparency applied so it looks like the screen darkens except where the hole is. However, the black edges of the sprite end at the edge of the sprite instead of covering the whole screen.

I am able to do this with my own custom quad with edge repeat enabled for the texture, but the material/shader I use for it doesn't play well with some NGUI elements for blending. Some NGUI elements simply disappear behind the non-transparent part of the texture.

I've attached a screenshot to help you visualize what I'm talking about. The technique in the screenshot is actually the spotlight sprite surrounded by black sprites, but on some PC's you can see a small gap between the sprites, particularly when the sprites are scaled larger than actual pixel size (which is necessary to get various spotlight sizes).

Gillissie

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 48
    • View Profile
Re: suggestion: inverted SlicedSprite
« Reply #4 on: December 04, 2012, 01:58:37 PM »
However, you are correct. I can probably use the UISlicedSprite class as a starting point and make my own version.

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
Re: suggestion: inverted SlicedSprite
« Reply #5 on: December 04, 2012, 04:30:52 PM »
Yeah I see now, and yes, this seems like something that many people could need, BUT I don't know if we can consider that as part of a "basic" UI component.

What do you think Aren ? It seems cool :)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: suggestion: inverted SlicedSprite
« Reply #6 on: December 05, 2012, 03:39:28 AM »
That's a pretty custom widget. Code it! ;)

Gillissie

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 48
    • View Profile
Re: suggestion: inverted SlicedSprite
« Reply #7 on: December 05, 2012, 09:29:49 AM »
I just took a gander at the code for UISlicedSprite. What would probably take me all day to decipher would probably take you 15 minutes since you know how the code already works (there's not a lot of comments in there explaining how the UV coordinates are set). Any chance you could write a new version of UISlicedSprite called UISlicedInvertedSprite for us, pretty please?

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
Re: suggestion: inverted SlicedSprite
« Reply #8 on: December 05, 2012, 09:37:31 AM »
Ahah, I don't want to give you some work Aren, but I think this is a nice new widget :)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: suggestion: inverted SlicedSprite
« Reply #9 on: December 05, 2012, 06:43:18 PM »
Then code it ;)

I am stupidly busy with Unity, upcoming Tasharen Networking package, and a dozen other things.

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
Re: suggestion: inverted SlicedSprite
« Reply #10 on: December 05, 2012, 06:44:22 PM »
hehe too busy too, sorry :s

Gillissie

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 48
    • View Profile
Re: suggestion: inverted SlicedSprite
« Reply #11 on: December 17, 2012, 10:30:36 AM »
Another one of our programmers took this on, and succeeded. We now have a UIInvertedSlicedSprite widget. Unfortunately, I'm not allowed to share our code.