0
I have a dictionary with a string for a key, and a string array for a value. I’d like to be able to call for a value of the array in a single step, but I’m running into problems.
This works:
var MyDictionary : Dictionary.<String,String[]>;
var tempVar : String[];
function Start(){
MyDictionary = ("Key Name", ["Value 1", "Value 2", "Value 3"]);
tempVar = MyDictionary["Key Name"];
Debug.Log(tempVar[0]);
}
But if I try to save a step and jump direction into the dictionary, like below, I get an error saying ‘The given key was not present in the dictionary.’ Am I stuck using an intermediate variable, or is there a way around this?
var MyDictionary : Dictionary.<String,String[]>;
function Start(){
MyDictionary = ("Key Name", ["Value 1", "Value 2", "Value 3"]);
Debug.Log(MyDictionary["Key Name"][0]);
}