Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: drewradley on May 22, 2013, 12:01:25 PM

Title: Popup menu highlight sprite off center
Post by: drewradley 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!
Title: Re: Popup menu highlight sprite off center
Post by: ArenMook on May 22, 2013, 09:48:01 PM
I've never seen that. Perhaps your background sprite has padding on it? Remove it.
Title: Re: Popup menu highlight sprite off center
Post by: drewradley on May 22, 2013, 10:33:58 PM
No padding on the sprite.
Title: Re: Popup menu highlight sprite off center
Post by: ArenMook 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.
Title: Re: Popup menu highlight sprite off center
Post by: drewradley 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.
Title: Re: Popup menu highlight sprite off center
Post by: ArenMook 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.
Title: Re: Popup menu highlight sprite off center
Post by: armitage1982 on May 29, 2013, 12:44:37 PM
(http://img11.hostingpics.net/pics/687814NGUIPopupListBug.jpg)
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...
Title: Re: Popup menu highlight sprite off center
Post by: ArenMook on May 30, 2013, 12:14:25 AM
Keep in mind "static" game object, and "static" flag on UIPanel are two very different things.
Title: Re: Popup menu highlight sprite off center
Post by: armitage1982 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.
Title: Re: Popup menu highlight sprite off center
Post by: paw9000 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.
Title: Re: Popup menu highlight sprite off center
Post by: armitage1982 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.
Title: Re: Popup menu highlight sprite off center
Post by: FeatureCreep 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;

Title: Re: Popup menu highlight sprite off center
Post by: ArenMook 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.
Title: Re: Popup menu highlight sprite off center
Post by: Ksavio 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.