Hi I am new to unity and would like to ask if there exist assets or unity built-in components to achieve a tree view display given a dictionary of Code (CSharp): Dictionary<List<string>, string> . For e.g, a dictionary with 2 pairs of keys & values will display something similar to the image below, assuming that the List<string> only has 3 elements. Any suggestions such as existing guides/videos/ideas will be appreciated. Thank you!
I have never seen a dictionary which uses a List as a key. If your intention is to have a compound key (each key is made of three strings), then this will not work as you want because List is a reference type (it's a class). When a reference type is used as a key in a dictionary, by default the key is the reference itself, not it's contents. This means that even if you create two separate lists with the same three strings, they'll be considered as two different keys on the dictionary because what is used as a key is the reference to the List, not the List contents. For compound keys, you can use C# 7 tuples: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/value-tuples Also, read the Microsoft documentation about the Dictionary type to know more about how key lookup is done and the requirements: https://docs.microsoft.com/en-us/do...ons.generic.dictionary-2?view=net-5.0#remarks