Adding & Removing Elements
9_ScriptableDictionaries
Last updated
9_ScriptableDictionaries
Last updated
To add an entry into a scriptable dictionary is the same as adding an entry in a regular dictionary.
In this example, each element prefab has a component "AddRemoveElementToDictionary" attached to it. Navigate to the hierarchy and select one element template object (you can choose any element, but I will show Water):
Now, look in the inspector to check out its components:
The nice part about using a Dictionary, is that we can have different cases when the item is already in the dictionary or not. Here is how an entry is added or removed: