Author Topic: Fix for UISpriteAnimation bug...  (Read 2429 times)

terence

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 14
    • View Profile
Fix for UISpriteAnimation bug...
« on: November 21, 2012, 07:46:32 PM »
UISpriteAnimation has a bug where it calls makePixelPerfect after setting the sprite. Obviously if you resized the sprite that would cause problems. So to fix it I added an member variable to enable/disable this. Not sure if should post the fixes but here are the code portions.

UISpriteAnimationInspector line 54 onward
  1.                 bool makePixelPerfect = EditorGUILayout.Toggle ("Make Pixel Perfect",anim.makePixelPerfect);
  2.                
  3.                 if (anim.makePixelPerfect != makePixelPerfect)
  4.                 {
  5.                         NGUIEditorTools.RegisterUndo("Sprite Animation Change", anim);
  6.                         anim.makePixelPerfect = makePixelPerfect;
  7.                         EditorUtility.SetDirty(anim);
  8.                 }
  9.  

UISpriteAnimation
  1.         [HideInInspector][SerializeField] bool mMakePixelPerfect = true; // Line 21
  2.  
  3.         public bool loop { get { return mLoop; } set { mLoop = value; } }
  4.        
  5.         public bool makePixelPerfect { get { return mMakePixelPerfect; } set { mMakePixelPerfect = value; } } // Around Line 54
  6.  
  7.         // Around Line 88
  8.         if (mActive)
  9.         {
  10.                 mSprite.spriteName = mSpriteNames[mIndex];
  11.                 if (mMakePixelPerfect)
  12.                     mSprite.MakePixelPerfect();
  13.                 }
  14.        
  15.  
  16.  

Hope this make it into the next build..;P

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Fix for UISpriteAnimation bug...
« Reply #1 on: November 22, 2012, 12:34:24 AM »
I suggest resizing the parent, not the sprite that has the animation on it. It's exactly the same as you trying to resize an animated model that happens to have its root scale animated as well. Just leads to confusion.