I’m interested in creating a Dictionary to hold Markov Chain information in order to generate text. So I’d like to be able to create a Dictionary holding a variable length of items for each of its Keys. I’d also like to be able to update the mapping at runtime.
It would look something like this:
- Key1: Item1, Item2, Item3
- Key2: Item4
At runtime, I’d like to be able to say: “Append
table in my script prior to the
Start function. The var
table holds our mapping of Keys of type
String to Values of type
List.<int>, or Lists of integers.
1 2 3
>> in a row.
Then I fill the table with our test mappings.
1 2 3 4 5
As you can see, you can construct a List from an Array. Cool.
Start function, I iterate over the Keys in the Dictionary, Add the item
4 to the Value of Key
c, and print out the first item of each of the
values. Finally, we check to see whether
4 was appended to the desired entry.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Then I attach this script to the Main Camera of a fresh Scene for testing purposes. Bada bing, bada boom.
Attaching the script to any old object in the scene would work. I just chose the Main Camera because the camera object is there by default.