When we talk about collection data, we need to mention Dictionaries. A Dictionary is similar to a List. However, instead of accessing a certain element by index value, we use a string called key.
The Dictionary that you will probably be using the most often is called Hashtable
. Feel free to dive into the C# documentation after reading this chapter to discover all the bits of this powerful class.
Here are a few key properties of Hashtable
:
Hashtable
can be resized dynamically, likeList<T>
andArrayList
Hashtable
can store multiple data types at the same type, likeArrayList
- A public member
Hashtable
isn't visible in the UnityInspector
panel due to default inspector limitations
I want to make sure that you won't feel confused, so I will go straight to a simple example: