Author Topic: UIPopupList  (Read 55171 times)

kruncher

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 78
    • View Profile
Re: UIPopupList
« Reply #15 on: July 25, 2014, 08:02:34 PM »
I am also having an issue with colliders. I have used the option Extras | Switch to 2D Colliders with the "Control - Colored Popup List" prefab. The button part of the control shows the popup fine; but the item entries cannot be selected.

Am I doing something wrong? Perhaps I have forgotten to configure something somewhere?

Edit 1: It seems the 2D box colliders reappear when fiddling with "Size Y" value of the box collider and work for one go. The next time the popup is shown they cease to work again...

Edit 2: Increasing the font padding from Y=4 to Y=8 seems to do the trick...
« Last Edit: July 25, 2014, 08:13:03 PM by kruncher »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIPopupList
« Reply #16 on: July 26, 2014, 03:51:50 AM »
Seems to work fine here.

1. New scene.
2. Dragged in the Colored Popup List.
3. NGUI menu -> Extras -> Switch to 2D Colliders
4. Hit Play, click on the popup list, select items inside. Works as expected.

kruncher

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 78
    • View Profile
Re: UIPopupList
« Reply #17 on: July 26, 2014, 06:48:54 AM »
Interesting, since restarting Unity the problem no longer occurs in the original scene, neither does it occur upon creating new popup controls.

I was able to reproduce this yesterday without issue...

Nether-mind, it seems that it has sorted itself out! Thanks.

crusty210

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
Re: UIPopupList
« Reply #18 on: August 07, 2014, 08:11:44 PM »
I am having an issue where when I select a value from the list the list closes but the instance of Drop-Down list still remains in the hierarchy. Now when I click the popup again, another Drop-Down list instance is created in the hierarchy. Is there a way to destroy the previous instance?

I am using the following code to add items to the popup list

  1. nonExpandedCountriesPopup.GetComponent<UIPopupList>().items = masterHandler.GetComponent<MasterHandlerL1>().MasterCountries;

  1. MasterCountries
is the list that I am adding to the popup under the GameObject
  1. nonExpandedCountriesPopup

I tried using
  1. nonExpandedCountriesPopup.GetComponent<UIPopupList>().Close();
to close (destroy) the instance but it doesn't work

Any clues?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIPopupList
« Reply #19 on: August 08, 2014, 09:11:38 AM »
Popup list closes automatically, and there is nothing left when it's closed. If something is left in your case, check to see what you're doing different.

Also, you are assigning items incorrectly. You should not be assigning the entire list. You should be adding items to that list instead.

treydavis76

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: UIPopupList
« Reply #20 on: August 27, 2014, 02:59:37 PM »
I have a popup list with 38 buttons in the 'Options' box.  How do I apply script to those individual buttons in the list?  (Each button will make the camera move to a specific location in the scene).
I have javascript created, that controls the movement, but I need to know how to apply this script to those buttons in the dropdown list.
Thanks!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIPopupList
« Reply #21 on: August 28, 2014, 09:43:51 PM »
Drop-down list doesn't have buttons. It creates its content programmatically, and it's just a bunch of labels inside a sliced sprite. You would need to create a custom script to handle what you want done.

treydavis76

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: UIPopupList
« Reply #22 on: September 02, 2014, 12:02:21 PM »
Being very new to scripting in Unity, how would I go about writing a script for the options inside of the dropdown menu?  Basically for each one of the options, I want something to happen when I select an option.  At this point, I'll be happy if I can get an option to just show an object in the scene (like an arrow or something) when I click on it.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIPopupList
« Reply #23 on: September 02, 2014, 12:38:44 PM »
You can set an OnChange delegate with the popup list. What you do inside that function is up to you.

col000r

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 3
  • Posts: 43
  • Mighty Emperor of Planet "Home Office"
    • View Profile
    • BLACKISH
Re: UIPopupList
« Reply #24 on: October 13, 2014, 11:14:44 AM »
Is there an easy way to set the current selection from script?

I'm trying to do dropdown.value = "One of the available options"; but it doesn't seem to work.
Games: BLACKISH | Blog | Assets

nicloay

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: UIPopupList
« Reply #25 on: October 14, 2014, 12:44:57 AM »
Is there an easy way to set the current selection from script?

I'm trying to do dropdown.value = "One of the available options"; but it doesn't seem to work.

Hi, I've just faced the same problem, I had an event handler which stored selected data. and the problem was that initially UIPopupList  set default value from inspector, and my handler pick this value and rewrites actual value.
The solution was to unsubscribe from onChange method in Start and subscribe back after initial default value performed.

  1.         void Start ()
  2.         {              
  3.                 UIPopupList popup = GetComponentInChildren<UIPopupList>();
  4.                 EventDelegate.Remove(popup.onChange, new EventDelegate(this,"OnDifficultyChange"));
  5.                 popup.value = UserData.Instance.Difficulty.ToString();
  6.                 EventDelegate.Add(popup.onChange, new EventDelegate(this,"OnDifficultyChange"));
  7.         }
  8.  
  9.         public void OnDifficultyChange(){
  10.                 UserData.Instance.Difficulty = (Difficulty) System.Enum.Parse(typeof(Difficulty),  GetComponentInChildren<UIPopupList>().value);
  11.                 UserData.Instance.SaveChanges();
  12.         }
  13.  
  14.  

p.s. Probably there is more easy method to subscribe and unsubscribe from events.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIPopupList
« Reply #26 on: October 14, 2014, 03:52:16 PM »
Is there an easy way to set the current selection from script?

I'm trying to do dropdown.value = "One of the available options"; but it doesn't seem to work.
UIPopupList.value is it -- provided the "One of the available options" is a valid item that can be found in UIPopupList.items.

chiphuc113

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: UIPopupList
« Reply #27 on: May 10, 2015, 10:33:34 AM »
Hello everyone right now i have a error with uipopuplist.

when i change my scalingstyle in uiroot to constrained. UIPopupMenu will show wrong position when i change position of Uipopuplist go to the top-left of the screen. I don't know what going on here. Have anyone can help me out.

Thank a lots.

jfperusse_indie

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
Re: UIPopupList
« Reply #28 on: May 14, 2015, 12:18:16 PM »
Hi ArenMook,

When using the UIPopupList, we end up with buttons that are way too large (currently using SciFi Font - Normal, Font Size 80).

The problem seems to be in UIPopupList.cs, "public void Show ()", here:

  1. x = Mathf.Max(x, (max.x - min.x) * dynScale - (bgPadding.x + padding.x) * 2f);

It seems like dynScale should not be used here since min/max already used the proper rendered size of the text.

Removing dynScale makes our button fit the text perfectly.

Could you confirm that this is the proper fix? We are using the latest version of NGUI (3.8.2).

Thanks!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIPopupList
« Reply #29 on: May 14, 2015, 06:18:31 PM »
Seems reasonable to me. I'll change it on my end and post again if I notice any adverse effects.