Author Topic: UIPopupList item labels have a Z depth of -1  (Read 21518 times)

Wumpee

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 53
    • View Profile
UIPopupList item labels have a Z depth of -1
« on: July 30, 2015, 05:22:59 PM »
Hi, I was just wondering why the UIPopupList code puts the generated labels at a Z of -1?

I've noticed this causing issues. Some popup lists work, while others don't display their item labels all the time. Some times the labels will vanish the next time you click the popup.

Why is it being set to -1f in this code?

lbl.cachedTransform.localPosition = new Vector3(bgPadding.x + padding.x - lbl.pivotOffset.x, y, -1f);

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIPopupList item labels have a Z depth of -1
« Reply #1 on: July 31, 2015, 09:59:25 PM »
It shouldn't. Its depth is based on the depth of other things you have underneath the widget used to show it.

Current Pro build of NGUI has an option to make popup lists show on a separate panel, ensuring that they are always on top even when used in scroll views.

Wumpee

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 53
    • View Profile
Re: UIPopupList item labels have a Z depth of -1
« Reply #2 on: April 21, 2017, 11:33:05 PM »
In the latest version of NGUI, line 1043 is set as follows

lbl.cachedTransform.localPosition = new Vector3(bgPadding.x + padding.x - lbl.pivotOffset.x, y, -1);

Setting the -1 to 1 fixes this issue.

Wumpee

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 53
    • View Profile
Re: UIPopupList item labels have a Z depth of -1
« Reply #3 on: April 21, 2017, 11:37:36 PM »
Also, using the "On Top" option wasn't working for me. It was offsetting the position of the menu when it popped up.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIPopupList item labels have a Z depth of -1
« Reply #4 on: April 22, 2017, 11:51:16 AM »
-1 means closer to the camera. 1 means farther away. So unless your camera is pointing in the opposite direction, it should remain -1. Doing the opposite means clicks won't work, and the labels will be behind your popup.