Issue with printing lines from a dictionary to Unity console.
I was using VS 2015 Community outside of Unity to learn some stuff using Dictionaries. In the following code I have added items to the dictionary, however I cannot use the print() function the same way I would use the Console.WriteLine() function in VS. How can I accomplish this?
void Start () {
Dictionary<string, string> theDictionary = new Dictionary<string, string>();
theDictionary.Add("Test", "Def1");
theDictionary.Add("Get", "Money");
theDictionary.Add("Word3", "Definition3");
foreach (KeyValuePair<string, string> pair in theDictionary) {
Console.WriteLine("{0} {1}", pair.Key, pair.Value);
Console.ReadLine();
I want to print out items in the Unity console from the Dictionary.
Answer by Fexception · Nov 12, 2015 at 03:12 PM
I am an idiot. I didn't have my scene loaded with the game object holding the script. What I had is correct, and the way I printed using Unity was by assigning the key value pairs to strings and then concatenating them inside the print() function.
So both methods work. lol
Your answer
Follow this Question
Related Questions
Using a dictionary of two enums 0 Answers
Access Dictionary on other Script on Object 0 Answers
Dubugging in Visual Studio 2015, Unity 5.2 0 Answers
Is the visual studio account free ? 1 Answer