Author Topic: Reference atlases sometimes load the wrong atlas  (Read 2432 times)

gdeglin

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 3
  • Posts: 18
    • View Profile
Reference atlases sometimes load the wrong atlas
« on: May 30, 2013, 06:28:24 PM »
I've been tracking down memory leaks in my game and found a bad one in NGUI...

It seems that sometimes if a Sprite is linked to a reference atlas, and that reference atlas points to a standard low-resolution NGUI atlas, a high definition atlas will be loaded instead. The way to fix it has been to point the sprite directly to the low-res atlas, save the sprite as a prefab, then point the sprite it to the reference atlas again, and save as a prefab again.

Seems like maybe there's some weird state that Sprites can get into where they point to the wrong atlas unless you reset them through the steps above.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Reference atlases sometimes load the wrong atlas
« Reply #1 on: May 30, 2013, 07:55:55 PM »
Eh? Reference atlases and fonts point only to what you told it. A high-res atlas will not be loaded unless you tell it to, or unless something is actually referencing it. Your issue is not in NGUI.

gdeglin

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 3
  • Posts: 18
    • View Profile
Re: Reference atlases sometimes load the wrong atlas
« Reply #2 on: May 30, 2013, 09:09:40 PM »
Definitely an issue in NGUI here. I recorded a video demonstration and I'll send you the link via the contact form.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Reference atlases sometimes load the wrong atlas
« Reply #3 on: May 31, 2013, 01:50:54 PM »
The file link you sent me is broken.

NGUI will not magically find your high-res atlas unless you do it yourself. Think about it -- how would NGUI know anything about your high-res atlas? Reference atlas points to one, and only one atlas.

gdeglin

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 3
  • Posts: 18
    • View Profile
Re: Reference atlases sometimes load the wrong atlas
« Reply #4 on: May 31, 2013, 03:29:28 PM »
Yes, of course. I think that some value referencing the HD atlas gets saved inside either the Sprite or the Reference Atlas, and in some cases that reference is not properly cleared up. The sprite or atlas that's causing the problem may have previously pointed to the HD atlas, so that's when that reference might have been created.

I've tried to debug the issue myself, but haven't been able to track down exactly what might be causing it yet.

The video will show you what I mean. I just uploaded it to an unlisted youtube URL and sent you that.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Reference atlases sometimes load the wrong atlas
« Reply #5 on: June 01, 2013, 01:40:28 AM »
Reference to the last atlas to be used is saved on the editor side so that when you create a new widget, it will automatically use that atlas. This only happens in the editor, as it's done by an editor-only script. You're chasing ghosts. :P