I am trying to add dictionary keys with player-defined values into a list, for example if playertypes 1 into input field, the programm will add into the list all keys with value 1, but i can’t figure out how
1 Answer
1Get the input in the code and use its .text value. With that value you can now get elements out of a dictionary like:
Dictionary<string, GameObject> dictionary = new Dictionary<string, GameObject>();
InputField input = FindObjectOfType<InputField>();
input.text = "foo";
GameObject elementFromDictionary = dictionary[input.text];
If you want to populate a dictionary by player defined key and value then get the values and add it like this:
Dictionary<string, GameObject> dictionary = new Dictionary<string, GameObject>();
string key = "foo"; // Get this from whatever the player enters
GameObject foo = new GameObject(); // This is the userdefined value
dictionary.Add(key, foo); // pass the key and the stuff you want to have in the dictionary
I'm sorry but this doesn't help me. I already have values and keys stored in Dictionary. What I want to know is how to put it's keys that have the user defined value into a list
– CrashCZ
Thanks Bunny for your answer, it worked I will analyze your answer. And don't worry, I'm not "taking" or "coyping" textures, I'm just reading textures.
– z3nth10nHow could I create the 2 remaining quads in order to make it visible on all directions?
– z3nth10n