unity-game-enginengui

How to 9-slice a sprite while keeping the center not scaled?


I wonder is there any way to slice this sprite(dialog pop up thing) that could keep the bottom center (the upside-down triangle) not scaled? I'm using nGUI if it matters.

Image inspector properties


Solution

  • Nope

    Sorry, but that's how 9-slice scaling works. You would need 25 slice scaling to do what you're looking for and that's overkill for most things, so I've never seen an implementation.

    What to do instead...

    Break up your sprite into two pieces: the 9-slice portion and the "notch" portion. Then just position the notch to be in the right place.

    I haven't used nGUI (only iGUI and the Unity native--both old and new) so I'm not sure on the precise nature of how nGUI will let you do that, but you'd still need two sprites, one of which is scaled and the other one which isn't, positioned either manually or through parent-child relative relationship. If your dialog is always the same width, it'll be pretty straight forward. If not, it might be more challenging.

    A few other things: