Search Unity

How to make a 9 scale sprite in the new 4.6 UI

Discussion in 'UGUI & TextMesh Pro' started by Bruder, Jan 25, 2015.

  1. Bruder

    Bruder

    Joined:
    Aug 9, 2014
    Posts:
    56
    Hi All,

    I'm using the new 4.6 UI Image and i want to create a scaled button image that can be stretched easily.
    For example:

    Fig1 is the original button
    Fig2 is what i get when i scale up the image
    Fig3 is what i expect to get when i scale up the image


    I know that other platforms there is 9 scale option:


    Is there a way to make 9 scale in Unity?
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Edit the borders in the sprite editor.

    --Eric
     
    varumora likes this.
  3. Bruder

    Bruder

    Joined:
    Aug 9, 2014
    Posts:
    56
    Hi Eric,

    Thanks for the response!

    I have tried making a border but still the picture doesn't look good when stretching it.

    This is the border:
    upload_2015-1-26_5-51-8.png

    And here is the result (i added also the inspector):

    upload_2015-1-26_5-51-39.png

    Any ideas why the area out side of the borders are also stretched?
     

    Attached Files:

  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Slicing like that can't work since you have curved sections mixed in with the straight sections. You need to move the slices closer together, so the curves are isolated in their own sections. Also the image would benefit from extending the middle section vertically a bit, to give the slicing something to work with. As it is, the horizontal slices would have to be nearly touching, and it's hard to tell if it would quite work. On the other hand, the horizontal straight section is needlessly extended and could be mostly eliminated; you only need a couple of pixels.

    --Eric
     
    Bruder likes this.
  5. Bruder

    Bruder

    Joined:
    Aug 9, 2014
    Posts:
    56
    I did :)

    The screenshot was taken before i did, but the result is after the "apply".

    Still same problem...
     
  6. Bruder

    Bruder

    Joined:
    Aug 9, 2014
    Posts:
    56
    Hi Erik,

    You are right! thanks a lot!
    I have sliced it wrong.

    This is how i sliced it now and it is working:
    upload_2015-1-26_6-9-3.png
     
  7. Derek-Wong

    Derek-Wong

    Joined:
    Jan 5, 2015
    Posts:
    16
    you can also scaled the image smaller, say 0.5 in x and y to make it start to slide properly easier~