Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

9-Slice equivalent in Unity

Discussion in 'Immediate Mode GUI (IMGUI)' started by auzette, May 13, 2009.

  1. auzette

    auzette

    Joined:
    Mar 23, 2009
    Posts:
    74
    Hey there. In past Flash projects, we made use of 9-slicing, a technique used on elements such as buttons to make the button stretch in a specified middle portion of a button while *not* stretching defined edges of a button (so it doesn't *look* stretched around the edges).

    Looking at the skin and style settings, I've tested some of the values (offsets, particularly) to achieve the same effect, but haven't had success.

    Is there a way to achieve 9-slice like behavior with styles? I'd love to be able to use a single button image across the project to handle various sizes of buttons.

    Thanks.
     
  2. HiggyB

    HiggyB

    Unity Product Evangelist

    Joined:
    Dec 8, 2006
    Posts:
    6,183
    Yes, that's exactly how our GUI works. You provide an image, then you specify in your Skin or Style the amount of padding to use for the edges/corners so as not to stretch. Download the built-in GUI skin and have a closer look and you'll see what I'm talking about (I believe it's the border property in particular).
     
  3. auzette

    auzette

    Joined:
    Mar 23, 2009
    Posts:
    74
    Ah!!!! The padding. Duh. Thanks!
     
  4. richierich1204

    richierich1204

    Joined:
    May 20, 2010
    Posts:
    45
    Using this method I am able to get the corners to display correctly, but the interior stretches the texture. Is there a way to scale the texture on the interior as well?
     
  5. Nition

    Nition

    Joined:
    Jul 4, 2012
    Posts:
    781
    Border does the interior slicing.
     
  6. pengo

    pengo

    Joined:
    Jun 3, 2013
    Posts:
    5