Author Topic: FIX for 'Out of Memory' error if using tiled sprite with zero-sized mid-section  (Read 1206 times)

dandrea

  • Newbie
  • *
  • Thank You
  • -Given: 6
  • -Receive: 2
  • Posts: 23
    • View Profile
On NGUI 3.5.5.

I'm used to creating round bitmaps and setting their borders so the middle section ends up with zero-width. This way I can use them as a circle or as a capsule, just changing the width. I accidentally changed the sprite to Tiled and the console spat an Out of Memory error on me and NGUI stopped drawing.

After looking around, we came up with a work-around:

UISPrite.cs, after line 792, after "size *= atlas.pixelSize;":
  1.  
  2.     if (size.x <= 0 || size.y <= 0) {
  3.  
  4.       return;
  5.     }
  6.  
  7.  

The offending sprite will no longer draw, but the remaining UI will.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Hmm... interesting. Thanks, although I'd prefer to have it as:
  1. if (size.x < 2f || size.y < 2f) return;