1
NGUI 3 Support / Bug: UIPopupList position bug when the panel is offset from the panel's parent
« on: June 29, 2016, 07:49:55 AM »
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:
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:
- Transform pt = mPanel.cachedTransform.parent;
- if (pt != null)
- {
- min = mPanel.cachedTransform.TransformPoint(min);
- max = mPanel.cachedTransform.TransformPoint(max);
- min = pt.InverseTransformPoint(min);
- max = pt.InverseTransformPoint(max);
- }