Dictionaries Setup
v4.0
Last updated
v4.0
Last updated
Dictionaries are included in most Game Module objects. However, they can be used in any class you create as well.
When viewing a Game Module object (scriptable object) in the Inspector, you should find a large "Manage" button at the top of the window.
This button will open an Editor Window where you can view, and sometimes edit, various aspects of the objects. Each window will have a "Type" drop down, where you can select which "object type" you'd like to manage.
Remember, the "object type" is the name of the folder the game module object is in!
Select the type you'd like to manage, and navigate to the "Dictionaries" tab. There, you can add new Keys to the dictionaries on all of the objects of that type. While the values will be different, each game module object of a specific "object type" should have the same dictionary Keys.
When viewing Dictionaries panel of the Game Module object in the Inspector, each Key is represented by large header button, which toggles on and off viewing the details of that Key. Without adding information, each Key has 0 types and 0 objects.
Choose a type from the drop down list and click "Add" to add that type to the view. You'll next need to add values. Some types require an object, such as a Sprite
or AudioClip
. For these, you can either drag and drop an object into the yellow object field, or click it to choose an object.
Others, like the String
field, allow you to optionally enter a value and then click "Add" to add it to the list. You can add an empty value.
Still others, like the Vector3
type, have just an "Add" button, and you can enter specific values after adding items to the list.
If you have multiple items in the list, you can use the arrow buttons to change the order. Very often, lists will only have one value, but they can have many, and there are helper methods to return a specific value, or even a random value.