Author Topic: Popup menu highlight sprite off center  (Read 13317 times)

drewradley

  • Guest
Popup menu highlight sprite off center
« on: May 22, 2013, 12:01:25 PM »
Hi, I've set up a popup menu and for some reason the highlight sprite starts off low and to the left. It snaps back to place when I move the mouse to a menu item, but since I am making a mobile game, it stays there until they click on a menu item. What could be causing this and how can I fix it? Thanks!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Popup menu highlight sprite off center
« Reply #1 on: May 22, 2013, 09:48:01 PM »
I've never seen that. Perhaps your background sprite has padding on it? Remove it.

drewradley

  • Guest
Re: Popup menu highlight sprite off center
« Reply #2 on: May 22, 2013, 10:33:58 PM »
No padding on the sprite.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Popup menu highlight sprite off center
« Reply #3 on: May 23, 2013, 12:18:58 PM »
One other thing to check is to make sure that the panel is not marked as static.

drewradley

  • Guest
Re: Popup menu highlight sprite off center
« Reply #4 on: May 24, 2013, 07:41:46 AM »
No, the panel is not set to static. How can I get rid of the highlight sprite? I don't exactly need it with touch. I tried just removing the sprite from the popuplist pull down menu in the inspector, but NGUI won't let me. I'm good with editing the code to do this, I just don't want to screw anything up by fumbling around in there.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Popup menu highlight sprite off center
« Reply #5 on: May 24, 2013, 05:45:46 PM »
The code is open for you to modify to suit your needs, so just change UIPopupList or make a copy of it and change that -- it's up to you.

armitage1982

  • Newbie
  • *
  • Thank You
  • -Given: 7
  • -Receive: 1
  • Posts: 15
    • View Profile
Re: Popup menu highlight sprite off center
« Reply #6 on: May 29, 2013, 12:44:37 PM »

I got the exact same problem.

No parent are set to static and no padding on the background sprite.
I got 4 of these popup list in my panel, each are on a separate z-depth.

I try with text item (no smiley), different negative Z value but that did not fix it.
Anyway, I don't think I need to mess with position Z since the Highlight sprite should simply focus on the selected item when the popup list is opening.

I got this with Popup Menu too.

When I randomly edit one of the 4 popup list, sometimes another got his highlight correctly fixed. ???

The parameters are pretty much the default one, except position is set to below and padding to x=5 y=4.
I also try the default one of course...

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Popup menu highlight sprite off center
« Reply #7 on: May 30, 2013, 12:14:25 AM »
Keep in mind "static" game object, and "static" flag on UIPanel are two very different things.

armitage1982

  • Newbie
  • *
  • Thank You
  • -Given: 7
  • -Receive: 1
  • Posts: 15
    • View Profile
Re: Popup menu highlight sprite off center
« Reply #8 on: May 30, 2013, 02:26:51 AM »
Ok, but I don't have any Panels marked as static or any objects flagged as (unity) static currently...
I will have a look at the OnClick code of the popup list to see if I find something weird.

paw9000

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 5
    • View Profile
    • Precocial Software LLC
Re: Popup menu highlight sprite off center
« Reply #9 on: June 16, 2013, 01:48:55 AM »
I was having the same problem.  popup menu highligh off center when I moused over.  For me the cause was that the third entry under the UIPopup List (Script) for my popup Menu for "Text Label" was set to none.  Once I dragged in the Label that is the child of the Popup menu in my Hierarchy the problem no longer happened.
Download my free 3d Unit Origami modeling app made with NGUI at http://www.precocialsoftware.com

armitage1982

  • Newbie
  • *
  • Thank You
  • -Given: 7
  • -Receive: 1
  • Posts: 15
    • View Profile
Re: Popup menu highlight sprite off center
« Reply #10 on: June 16, 2013, 03:44:58 AM »
Hum...
So maybe it's the same problem since I'm using a "smiley" text occurence to simulate icons in my popuplist.
The fact that the selection sometimes work on another popuplist in the same scene is probably because I remove/add color when selected by another player.

FeatureCreep

  • Guest
Re: Popup menu highlight sprite off center
« Reply #11 on: June 23, 2013, 10:15:39 PM »
This highlight being in the wrong place is due to the highlight sprite's position not being initialized due to a bug in the latest version of NGUI (2.6.3) in the UIPopupList.

If you comment out the following two lines in NGUI\Scripts\Interaction\UIPopupList.cs, the highlight is placed correctly. The commented out code assumes it is a drop down type control rather than a menu type control.

In UIPopupList.Start(), comment out:
   if (textLabel != null)

In UIPopupList.selection (set), comment out:
   if (textLabel == null) mSelectedItem = null;


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Popup menu highlight sprite off center
« Reply #12 on: June 24, 2013, 10:32:59 AM »
Interesting... thanks for looking into it. I'll make the changes and see how it behaves. So far so good.

Ksavio

  • Guest
Re: Popup menu highlight sprite off center
« Reply #13 on: July 05, 2013, 01:43:37 AM »
Hi all.
Had the same problem, solved it by doing what FeatureCreep said, and also adding the following code:
   Highlight(lbl,false);
in method:
   void OnClick()
before lines:
   // Move the selection here if this is the right label
   if (mSelectedItem == s) Highlight(lbl, true);
Please answer, if it helped.