Author Topic: [WIP] UI components "pack" -- Scrollable PopupList available for download  (Read 19704 times)

Lumos

  • Newbie
  • *
  • Thank You
  • -Given: 7
  • -Receive: 4
  • Posts: 21
    • View Profile
Greetings!
A few days ago, I was trying to build my game's options menu. NGUI is a blast, but creating a potentially long list of resolutions meant that I couldn't use NGUI's built-in PopupList, as that component always insists on showing the entire list. I am targeting the PC, and I don't want to do a cheap "here you go, a couple of buttons with pre-determined resolutions" solution. I needed a replacement. Tried using some sort of buttons instantiated at runtime, but it was honestly terrible, so I searched for a replacement. It appears that a member of this forum, by the name of "adam718" had written something like that about two years ago. I tried it, didn't work even after porting. Therefore, I trashed that idea as well.
And so, in the end, despite being quite inexperienced with NGUI (I am well-acquainted with programming, though), I sat down and wrote a new list, based on the current one. This one is scrollable.

So what's this all about? I'm intending to create a few more components for NGUI, then publish them on the Asset Store (as Aren has stated that he doesn't want his source code floating around everywhere, and the Asset Store should deal with that with the "requires NGUI" thing they've got going on). I'll likely provide the entire pack for free, or for a couple of euro only, as I am quite broke at the moment - as a symbolic price, tribute to the free time I've spent on them.
So, what do you guys think? Is anyone interested in a component pack?

After this scrollable list, I'll do some sort of a list which has got only one element showing up at a time, with left/right arrows for selecting the other elements (Battlefield 3/4 options menu style), which could possibly also show the amount of elements using some sort of a small sprite. I had something else on my mind as well, but I seem to have forgotten it at the moment. :P
So, if anyone's interested, post here. I am likely to do requests, so if you want to see a specific GUI component NGUI's been lacking, and you can't be arsed/don't know how/don't want to write one yourself, just post here and (if it's not too complicated) I'll make one and include it in the pack.

Current projects and Unity 4.6 GUI and whatnot render me unlikely to continue using NGUI, so the above paragraph is very unlikely. However, you can now grab the scrollable list if you want to.

In any case, let's get to demonstrating the scrollable list.
Ladies and gentlement, without further ado, I give you the...

> Scrollable Popup List
It's got its own scrollbar, and can be quite small...


Positioning it above works as expected, and how big it is is up to you to decide.
The Inspector is naturally based on the existing ones from NGUI, but exposes more variables - particularly these relating to the scrollbar.

The Scrollable Popup List is great for displaying long lists, unlike the regular PopupLists which may, at one point, become longer than your screen. This one's "open size" is dictated by the "Max Height" variable exposed in the Inspector. (Setting it to 0 will give the same results as a regular PopupList, and you can change that during run-time if you so desire for whatever reason.) Naturally, you can populate such a list during run-time in rather the same way you'd do with a regular list.
The scrollbar handles clicking and dragging, and behaves just as a scrollbar should. Most of it is also exposed (including the colours its foreground and background sprites use), so you can customise it as well.

A scrollable PopupList (or, should I say, a ListBox for those familiar with .NET development) is perfect for displaying a variety of different things. I wrote it because I needed a resolutions list, but it can be used for basically anything - as a debugging tool to display all items in your new RPG, as a complicated dynamic statistics graph filter for that 4X strategy game you're working on, or perhaps as a list of all maps during your new FPS's server hosting screen.
It was odd to me that NGUI didn't have one of these by default. One'd think that such functionality is indispensable.

Limitations:
- Requires a minimal modification to the UILabel class in order to display the choices on the given label.
- Does not support phone-style dragging directly on top of the list. I do things for the PC, not for random portable devices. PC master race FTW. :D

Note: This list does exhibit some strange behaviour from time to time, IIRC, so keep in mind that it's not perfect. YMMV.
DOWNLOAD (.zip, 9.41 KB)

"Installation" instructions:
Just like every other UI component, just drop the files in some proper folders. You can use a regular PopupList prefab, and just replace the default list script with this one.
However, one modification should be made to the UILabel class in order to allow the labels to handle updates from this specific kind of list. Open up the label file, and find the SetCurrentSelection() function and add the part after my comment from the excerpt below:
  1.     /// <summary>
  2.     /// Convenience function, in case you wanted to automatically set some label's text
  3.     /// by selecting a value in the UIPopupList.
  4.     /// </summary>
  5.     public void SetCurrentSelection ()
  6.     {
  7.         if (UIPopupList.current != null)
  8.         {
  9.             text = UIPopupList.current.isLocalized ?
  10.                 Localization.Get(UIPopupList.current.value) :
  11.                 UIPopupList.current.value;
  12.         }
  13.         // Lumos: Scrollable popup lists
  14.         else if (UIScrollablePopupList.current != null)
  15.         {
  16.             text = UIScrollablePopupList.current.isLocalized ?
  17.                 Localization.Get(UIScrollablePopupList.current.value) :
  18.                 UIScrollablePopupList.current.value;
  19.         }
  20.     }
  21.  


Hope I've interested someone. I do feel like doing a few more components.

Any comments, opinions, remarks? Let me know.
« Last Edit: February 19, 2015, 12:08:02 PM by Lumos »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: [WIP] Creating a UI Components pack! (Want something? Post here!)
« Reply #1 on: June 06, 2014, 01:43:39 AM »
Very nice!

NaxIonz

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 70
    • View Profile
Re: [WIP] Creating a UI Components pack! (Want something? Post here!)
« Reply #2 on: June 09, 2014, 02:15:59 PM »
I'm definitely interested in this!!
How would I get my hands on that scrollable popup list?

mpintar

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
Re: [WIP] Creating a UI Components pack! (Want something? Post here!)
« Reply #3 on: June 09, 2014, 04:31:42 PM »
Yeah this would definitely be useful!

I was just started to write my own scrollable popup list last week for the exact reason you are. When you do release it I would love to give you feedback on your component(s).

Lumos

  • Newbie
  • *
  • Thank You
  • -Given: 7
  • -Receive: 4
  • Posts: 21
    • View Profile
Re: [WIP] Creating a UI Components pack! (Want something? Post here!)
« Reply #4 on: June 13, 2014, 09:03:28 AM »
Thanks for the interest! I've unfortunately been quite busy with other things, so I've not yet had the chance to sit down and create the other thingies I wanted to do, so the actual release of the pack of stuff is delayed for now.

However, given that there's interest, and that everything always needs testing, I'll send you guys the list right now, though PMs, so the code remains safe. Please check the list's performance out. And be sure to tell me if there's something unexpected going on with it!

charlie.szu

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
Re: [WIP] Creating a UI Components pack! (Want something? Post here!)
« Reply #5 on: June 25, 2014, 12:14:01 AM »
I'm definitely interested in this!!
Can i get a copy of the test-version? i would love to send you any feedback.

NitrOxygeN

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
Re: [WIP] Creating a UI Components pack! (Want something? Post here!)
« Reply #6 on: July 02, 2014, 02:31:29 AM »
Hey, I'm interested in it too. Just started to create something like that. I'll be appreciated to get a copy of this script. Maybe I can be helpful with it.

curlyfrydesign

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: [WIP] Creating a UI Components pack! (Want something? Post here!)
« Reply #7 on: July 28, 2014, 09:40:57 AM »
I am really interested in this! Is there anyway you might post the script here in this thread?

devdem

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
Re: [WIP] Creating a UI Components pack! (Want something? Post here!)
« Reply #8 on: July 29, 2014, 10:48:02 AM »
Can you please give me your test version of scrollable list?

e-tip

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 10
    • View Profile
Re: [WIP] Creating a UI Components pack! (Want something? Post here!)
« Reply #9 on: August 04, 2014, 05:44:38 AM »
I will be very glad if i could use the scollable list :)

Lumos

  • Newbie
  • *
  • Thank You
  • -Given: 7
  • -Receive: 4
  • Posts: 21
    • View Profile
Re: [WIP] Creating a UI Components pack! (Want something? Post here!)
« Reply #10 on: August 15, 2014, 04:15:43 AM »
Holy shit! I am flattered by the amount of interest this little modification has done. I've still not created the other stuff (you know how it goes when the REAL work rains down upon you), but I've sent PMs to everyone interested. Now, I've simply got to find a couple of hours to work on the other stuff and to pack 'em up nicely.

So, hope you guys find this thing useful, and once again - if there's anything that shouldn't happen, please tell me, so I can investigate.

bugangaopan

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 1
    • View Profile
Re: [WIP] Creating a UI Components pack! (Want something? Post here!)
« Reply #11 on: August 21, 2014, 02:07:17 AM »
I'm a beginner,and how can i achieve the function like that you shown to us.

RamblingJosh

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
Re: [WIP] Creating a UI Components pack! (Want something? Post here!)
« Reply #12 on: August 22, 2014, 03:44:34 PM »
I am looking for exactly this functionality. Would it be possible to provide me with what you currently have, or else an ETA on the "official" release?

Somethingintheway

  • Newbie
  • *
  • Thank You
  • -Given: 5
  • -Receive: 0
  • Posts: 1
    • View Profile
Re: [WIP] Creating a UI Components pack! (Want something? Post here!)
« Reply #13 on: September 19, 2014, 06:33:19 AM »
It would be awesome if you could share this, I have a long list and this would solve everything that's wrong with it :)

wivlaro

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
Re: [WIP] Creating a UI Components pack! (Want something? Post here!)
« Reply #14 on: October 15, 2014, 02:01:06 AM »
Yes please do share! Thanks.