Optimization problems with large amounts of data in Dropdowns.

Hello everyone. I am trying to make a form in UI in Unity where I want to put two Dropdowns (Countries and Cities). The problem is that when selecting the country, everything is ok, but when trying to select the cities that belong to the country, Unity is blocked until it loads, 1-4 minutes. The cities to choose from are filtered based on the selected country. As you all know, dropdowns instantiate their options through a template. The problem comes from the large number of options that must be instantiated depending on the number of cities. An extreme case is the United States of America, it has around 20,000 cities, it is unmanageable. Does anyone know of any trick or method to be able to display this data in this Dropdown format or similar?

I don’t have a complete solution for you, but I have some suggestions that may help a little.

You often see web pages and forms where you fill in location info for the United States add an extra “State” selection when you choose United States as a country. That would reduce the number of cities you need to populate the list with to be only those for a single state, which should speed it up. Some even have you select the County within the state. I am sure other large countries like China and Russia it would be possible to do something similar.

Another option to reduce the size of the city list, and so speed it up, would be to allow you to select the first letter for the city. Any letter that has no matching city name would either not appear or be greyed out. Then you only need to have a list of cities that start with that letter, which will reduce the size of the list even further and make it much easier for the user to scroll through to find the right city.

If you aren’t doing it already, be sure to populate each next list using a method you fire off using StartCoroutine() as soon as something from the current list is selected. That gives you a slight head start in building the next list to display, which hopefully is completed by the time they select the next dropdown.

Simple programming tricks like this can reduce the size of your lists, which not only makes it faster, but also makes it easier on the end user so they don’t have to deal with large lists. I will be interested in seeing if anyone has a good suggestion on how to quickly build the lists themselves.