- Home /
Create List of Dictionaries C#
I'm using Parse (parse.com) to store saved games on the cloud. They limit what kind of data types you can use. I'm new to C# - usually I use Javascript but Parse does not work with Javascript
I'm iterating over all of the GameObjects in my scene and making a dictionary type for each one containing its name (string), x (int), y (int), rotation(float). I would like to store these items in a List.
var blocks = GameObject.FindGameObjectsWithTag ("GameItems");
foreach (var obj in blocks)
{
//Make a new dictionary and add to list
//IDictionary<string, object> levelBlocks = new Dictionary<string, object>{};
levelBlocks.Add("name", obj.name);
levelBlocks.Add("x", obj.transform.position.x);
levelBlocks.Add("y", obj.transform.position.y);
levelBlocks.Add("rotation", obj.transform.eulerAngles.z);
}
Answer by Benproductions1 · Feb 09, 2014 at 08:36 AM
Generic types can be nested:
//C#
List<Dictionary<string, object>>
//UnityScript
List.<Dictionary.<String, Object>>
Answer by Karsnen_2 · Nov 20, 2014 at 08:22 PM
The best resource to learn about arrays/list/dictionaries with Unity3d would be here. http://wiki.unity3d.com/index.php?title=Which_Kind_Of_Array_Or_Collection_Should_I_Use%3F
Your answer
Follow this Question
Related Questions
IDictionary 1 Answer
A node in a childnode? 1 Answer
How to check if the string is on a text file 0 Answers
Why can't Dictionaries have the same variables 2 Answers
need advise on creating and adding to a list and save it 1 Answer