Author Topic: How to set the border for the foreground and background images of a Scrollbar?  (Read 4796 times)

Nacho

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 12
    • View Profile
Hi! I'm trying to make a vertical scrollbar using my own assets. I have both foreground and background images (see the attachments) that, when drawn by NGUI, get uniformly scaled in the vertical axis. This is not what I want, since the foreground image has a small protuberance that I don't want to get stretched. How can I tell NGUI to only scale the pixels that are in the center of the image? I know that it can be done, since I've attached the debugger to NGUI's example #7 and found out that the scrollbar images from that example have a non-zero border.

Thanks in advance for your help!

--Nacho

JRoch

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 140
    • View Profile
Have you added your self-made scrollbar images to an atlas?  Once added to the atlas, have to set the border values so that, when used as a slicedsprite, it doesn't scale the border areas of the image?


ENAY

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 248
    • View Profile
Yep, you need a SlicedSprite. But you also need to set up your image in your atlas to support slices sprites.

Check out the Fantasy Atlas and look at the images in there, you will notice that they have padding at each corner, this is what allows them to restrict certainly pixels only.

JRoch

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 140
    • View Profile
I'm fairly sure you mean "border" not "padding".

Nacho

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 12
    • View Profile
Thank you for your replies!  :)

OK, so I've found out that in order to modify the border properties of a sprite inside an atlas I need to select its prefab. The problem I'm having right now is that my foreground image looks quite blurry when I compare it against the one used by the NGUI example (see attachment). When I imported the original PNG sprite before placing it into the atlas, I set its properties to "Texture type = GUI" and "Format = Truecolor". What am I missing here?

Thanks in advance,

--Nacho

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
NGUI changes the import settings of images you put into the atlas, so it doesn't matter.

Sprite preview will always look blurry if your sprite is small. It's just the effect of resizing a small sprite to a larger size. It's just a visual effect and shouldn't affect how your sprites look at their proper in-game size.

Nacho

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 12
    • View Profile
Thank you for your reply Aren, everything worked as expected  :)