Author Topic: UIPopupList popup isn't sizing and positioning correctly  (Read 3365 times)

Thurinus

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 27
    • View Profile
UIPopupList popup isn't sizing and positioning correctly
« on: November 21, 2014, 04:44:04 AM »
I'm creating a dropdown menu following the example scene's popup list, using my own sprites and font

Problem 1: dropdown sizing
the width of the dropdown is smaller than the original button that spawned the dropdown. Digging through the code, I found this line:

  1. // The triggering widget's width should be the minimum allowed width
  2. x = Mathf.Max(x, bounds.size.x * dynScale - (bgPadding.x + padding.x) * 2f);

The problem seems to stem from dynScale being indirectly calculated to be less than 1, from its activeFontScale assignment where it's stated to be fontSize / bitmapFont.defaultSize if a bitmap font is specified. The problem doesn't appear in the example scene because the dropdown font is native sized, but I have a big font that I've scaled down a bit. I hope I don't have to create another smaller font atlas to work around this :P

Problem 2: dropdown positioning
Seems like if the list is just a bit longer (say maybe 10 values or more), the dropdown will be positioned further down and no longer adjacent to its spawning button, even if it wouldn't go beyond the bottom of the window if positioned correctly. This happens in the example project if I add more options to either one of the example popup lists.

Am I missing something, or are these actual bugs?

Thanks for any help!
« Last Edit: November 21, 2014, 05:36:46 AM by Thurinus »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile

Thurinus

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 27
    • View Profile
Re: UIPopupList popup isn't sizing and positioning correctly
« Reply #2 on: November 22, 2014, 09:20:02 PM »
Thanks for the response Aren, that solves the 2nd problem. Is the solution to the first to remove dynScale from that equation?

Thanks!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIPopupList popup isn't sizing and positioning correctly
« Reply #3 on: November 25, 2014, 01:04:36 AM »
I don't quite understand #1. I know the popup list's size and position depends on the collection of widgets on which UIPopupList resides on (it collects all of them underneath it and uses combined dimensions). I also remember changing it recently for Windward...

Thurinus

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 27
    • View Profile
Re: UIPopupList popup isn't sizing and positioning correctly
« Reply #4 on: December 11, 2014, 12:41:21 AM »
Sorry for the late response - was on vacation and internet stopped after that.

So for a quick repro case, open up "Example 0 - Control Widgets.unity" and pick one of the popup lists. When run without any changes, "Control - Colored Popup List" looks like this:

The width of the dropdown box matches that of the original button. This is the desired outcome.

I made a font size change from 20 to 15 in the UIPopupList component here:


And this is what it looks like as a result:

dropdown box width no longer matches that of the original button.

The width discrepancy between the Dropdown box and the original button only seems to happen when the font size specified isn't the same as the font's original size. Removing "dynScale" in the line of code I mentioned in my first post seems to fix it, but I'd prefer it if I didn't have to modify NGUI code (I like to keep my 3rd party libraries untouched). Is this a bug, or intended behaviour?

Thanks!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIPopupList popup isn't sizing and positioning correctly
« Reply #5 on: December 11, 2014, 09:14:01 AM »
I vaguely remember it being intentional for looks... and something else in Windward.