Author Topic: Bug: UIPopupList position bug when the panel is offset from the panel's parent  (Read 7410 times)

wizardsmoke

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 5
  • Posts: 40
    • View Profile
I found a bug in UIPopupList that occurs when the hierarchy looks something like this:

UIRoot
  PanelParent (empty GameObject)
    UIPanel
      UIPopupList

There is a bit of code in UIPopupList.Show() that causes the position of the popup's generated "Drop-down" object to be based on the panel's parent even though the "Drop-down" object is still a child of the panel.  This causes a problem if the panel's local position is not (0,0,0).

This issue can be reproduced in Example 0 by rearranging your hierarchy as described.  I used a game window that was sized around 1920x1080, with the panel's parent anchored to the top-left corner of the screen.  The panel's clipping option was set to None.  With this setup, the popup works fine if the panel and popup are in the top-left quadrant of the screen.  If you move the panel (along with the popup) over to the bottom-right quadrant of the screen, you will see that the popup's "Drop-down" object will be constrained to the top-left quadrant of the screen.

Commenting out this code near the end of UIPopupList.Show() fixed this issue for me:

  1.                         Transform pt = mPanel.cachedTransform.parent;
  2.  
  3.                         if (pt != null)
  4.                         {
  5.                                 min = mPanel.cachedTransform.TransformPoint(min);
  6.                                 max = mPanel.cachedTransform.TransformPoint(max);
  7.                                 min = pt.InverseTransformPoint(min);
  8.                                 max = pt.InverseTransformPoint(max);
  9.                         }
  10.  

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Hmm... Thanks, I'll make the modifications on my end and see if this will cause any adverse effects.