Author Topic: Localization on UISprites: snap them...  (Read 2229 times)

Ernest

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 40
    • View Profile
Localization on UISprites: snap them...
« on: May 25, 2014, 05:11:22 AM »
Hi,

i don't want my localized sprites to be rescaled, but the MakePixelPerfect() function in UILocalize seems to do that (line 50).
How to manage that?! (aside comment the line?)

Ty.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Localization on UISprites: snap them...
« Reply #1 on: May 25, 2014, 02:09:43 PM »
It probably should just not MakePixelPerfect there, actually.

As a workaround, you can do something like caching the size you want, and set it back when the localize sets it, but that's a bit ugly.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Localization on UISprites: snap them...
« Reply #2 on: May 25, 2014, 08:10:04 PM »
Or just change the sprite to be of Sliced type. Then MakePixelPerfect won't do anything.

Ernest

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 40
    • View Profile
Re: Localization on UISprites: snap them...
« Reply #3 on: June 03, 2014, 03:59:45 AM »
Hey guys, thanks for the answers! Actually making the sprite a sliced sprite don't do the trick... This is because my sprite does not have border so the condition
  1. if (t == Type.Simple || t == Type.Filled || !sp.hasBorder)
in the MakePixelPerfect() function is validated (and it rescale my sprite).
I use the following workaround in UILocalize
  1. if(NGUITools.FindInParents<UIRoot>(sp.gameObject).scalingStyle == UIRoot.Scaling.PixelPerfect) sp.MakePixelPerfect();
because i'm always using a UIRoot setted on FixedSize, but i'm not sure this is a correct behaviour for those using PixelPerfect anyway...

ilookha

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 1
    • View Profile
Re: Localization on UISprites: snap them...
« Reply #4 on: July 13, 2014, 02:28:20 PM »
Bumping the thread, since I'm getting the same issue and it's a blocker for me. There's no way to have a localized scaled sprite! :( Setting type to "Sliced" doesn't help because of the above mentioned reason.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Localization on UISprites: snap them...
« Reply #5 on: July 13, 2014, 05:57:02 PM »
Scale the parent of the sprite, ilookha. Don't scale the sprite. Or just comment out that line if it really bothers you. NGUI comes with full source for a reason. ;)