Author Topic: Only use part of a sliced sprite  (Read 2363 times)

wbronchart

  • Guest
Only use part of a sliced sprite
« on: February 12, 2013, 10:02:17 AM »
Hi all,

I'm trying to make a horizontal menu bar similar to the one on this forum. I have one rounded corner sprite with borders setup in unity.

Now, I want to setup the buttons for the horizontal menu. The outer buttons will be rounded, the inner buttons will just be blocks.

So what I want to do is get the slicedsprite to just use a part of the original sprite in the atlas:


Is this possible with the current release? If not, how can I best approach this?

Thanks
Waldo

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile

wbronchart

  • Guest
Re: Only use part of a sliced sprite
« Reply #2 on: February 12, 2013, 10:27:06 AM »
Thanks for your response Aren

I don't think you understood my question. My atlassed sprite doesn't need to tile. I want to reuse the same texture in the atlas, but only part of it.

I set up 3 sliced sprites:
- The left button uses: TopLeft, TopCenter, CenterLeft, CenterCenter, BottomLeft and BottomCenter
- The middle button uses: TopCenter, CenterCenter, BottomCenter
- the right button uses: TopCenter, TopRight, CenterCenter, CenterRight, BottomCenter and BottomRight

To get this functionality, I basically need to put 3 different textures into the atlas. But they could actually be sharing the same texture space.

I may also use all of the parts of the sliced sprite if there's only one button in the horizontal menu, if you know what I mean :)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Only use part of a sliced sprite
« Reply #3 on: February 12, 2013, 10:29:40 AM »
Ah. All sprites are individually added to the atlas, so you can't do what you want without duplicating texture data.

On the bright side, the Unity's UI I am working on will let you specify the sliced border on each sprite individually. I don't know if it's any consolation or not though.

wbronchart

  • Guest
Re: Only use part of a sliced sprite
« Reply #4 on: February 12, 2013, 12:53:13 PM »
No worries, I just wanted to check if that functionality was already in there somewhere.

I wrote a SlicedSpritePart script that does what I need: