Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Customize Sprite Stretching ?

Discussion in 'UGUI & TextMesh Pro' started by perchik, Feb 6, 2015.

  1. perchik

    perchik

    Joined:
    Jul 25, 2012
    Posts:
    19
    Desired behavior:
    Desired.png

    Sprite:
    VertScrollbar.png

    Actual Behavior:
    VBarStretch.PNG


    In the sprite editor, I really want the top and bottom piece to scale with the appropriate aspect ratio and the middle to stretch to fill it in. Any idea how I can achieve this? I've also tried adding in 1px on the left and right to create a true 9 slice, it doesn't do anything better.
     
  2. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,683
    Hmm, will have a play. Do you have the sprite image to download?
     
  3. perchik

    perchik

    Joined:
    Jul 25, 2012
    Posts:
    19
  4. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,683
    How's this then?
    upload_2015-2-7_12-16-45.png

    The simple answer is to put your borders like this:
    upload_2015-2-7_12-18-2.png

    Hope this helps :D
     
  5. BMayne

    BMayne

    Joined:
    Aug 4, 2014
    Posts:
    186
    Hey there,

    The reason your object is not stretching like you like is because your image is too big. A sliced sprite only starts scaling once it's bigger then the world scale that sprite is set too. There is an easy way to tell how big an image is. Go to the Image component and instead of sliced sprite set it to simple. Then click Set Native Size. If I am correct you should see that your sprite grow in size.
     
  6. perchik

    perchik

    Joined:
    Jul 25, 2012
    Posts:
    19
    Oh interesting, Thanks guys! I think Simon's answer is probably the right direction to go in!
     
  7. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,683
    Awww shucks :D

    I would also reduce the image down to just the texture as well through, too much blanks space left and right :D
     
  8. perchik

    perchik

    Joined:
    Jul 25, 2012
    Posts:
    19
    Yeah, I expanded it to make it a power of two (64x64) >.>
     
    SimonDarksideJ likes this.