Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: dmaier on June 27, 2013, 09:24:44 AM

Title: UIPopupList issues
Post by: dmaier on June 27, 2013, 09:24:44 AM
Hi everybody! I'm using UIPopupList and have run into a few issues.

First, 9-slice scaling doesn't seem to work for the drop-down list highlight. I should note I'm using 3 atlases: SD, HD, and UHD. Only SD renders correctly. All other UI components render correctly with these atlases, so I don't think the atlases are at fault. I think the issue is somewhere in this line of code:

  1. // Scale the highlight sprite to envelop a single item
  2. mHighlight.cachedTransform.localScale = new Vector3(
  3.         x - (bgPadding.x + padding.x) * 2f + (hlsp.inner.xMin - hlsp.outer.xMin) * 2f,
  4.         fontScale + hlspHeight * 2f, 1f);
  5.  

Second, the "Drop-down list" component is never destroyed if it uses animation. This line will never destroy the list:

  1. Destroy(mChild, animSpeed);
  2.  

This means each time the list is opened and closed, the list lives on and will leak memory. Destroying the list immediately works, but then it won't animate out.

I started debugging these issues myself but realized I should probably broadcast out first to see if anyone has dealt with this. Any ideas?

Thanks!
Title: Re: UIPopupList issues
Post by: dmaier on June 27, 2013, 01:18:02 PM
FYI - I fixed part of this. Here are the relevant changes:

  1. // Scale the highlight sprite to envelop a single item
  2. float scaleFactor = 2f * atlas.pixelSize;
  3. mHighlight.cachedTransform.localScale = new Vector3(
  4.        x - (bgPadding.x + padding.x) * 2f + (hlsp.inner.xMin - hlsp.outer.xMin) * scaleFactor,
  5.        fontScale + hlspHeight * scaleFactor, 1f);
  6.  

and, in Highlight()

  1. float scaleFactor = atlas.pixelSize;
  2. float offsetX = (sp.inner.xMin - sp.outer.xMin) * scaleFactor;
  3. float offsetY = (sp.inner.yMin - sp.outer.yMin) * scaleFactor;
  4.  
Title: Re: UIPopupList issues
Post by: ArenMook on June 27, 2013, 01:59:14 PM
Sounds reasonable, I will add in your fix and see if it causes any adverse effects.
Title: Re: UIPopupList issues
Post by: dmaier on June 27, 2013, 02:13:24 PM
Great!

Also, I found out that the Destroy() problem was on my end. Somehow the timeScale in my project had been set to 0 so all timed Destroy()'s were failing.