Author Topic: UISprite's scale can't be saved  (Read 4591 times)

maoguo.zhang

  • Guest
UISprite's scale can't be saved
« on: June 27, 2013, 10:58:24 PM »
Hi,
I've downloaded the new version NGUI 2.6.3. I got a new problem with UISprite.
My sprite's orginal size is 213*211. I set the scale with 106*106 in the inspector, but this can't be saved and auto change to 213*211 after saving the scene.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UISprite's scale can't be saved
« Reply #1 on: June 28, 2013, 04:19:00 PM »
Nothing in NGUI will resize your sprite for you when you save the scene. Check other scripts you have on it.

maoguo.zhang

  • Guest
Re: UISprite's scale can't be saved
« Reply #2 on: July 08, 2013, 02:34:57 AM »


scale.x = Mathf.RoundToInt(rect.width * pixelSize) * Mathf.Sign(scale.x);
scale.y = Mathf.RoundToInt(rect.height * pixelSize) * Mathf.Sign(scale.y);
scale.z = 1f;
cachedTransform.localScale = scale;

If sprite type is simple, MakePixelPerfect will reset the scale to its actual pixel size.
« Last Edit: July 08, 2013, 02:45:14 AM by Dreamer »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UISprite's scale can't be saved
« Reply #3 on: July 08, 2013, 11:27:07 AM »
You didn't mention using an image button. Yes, image button forcefully changes the size of your sprite to make it pixel-perfect when it changes sprites -- and this is the intended behaviour. You shouldn't stretch simple sprites, it just causes them to look blurry and distorted. Consider using a sliced sprite instead.