Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Using Lists

Discussion in 'Scripting' started by yanuaris, Feb 28, 2016.

  1. yanuaris

    yanuaris

    Joined:
    Oct 16, 2015
    Posts:
    61
    I want to use the list class since it can contain generic informations...
    Such as referring the character stas base on their names, types, etc...

    Question is, what and how many value can i put in the dictionary?
    Is it possible for me to associate integers and strings to it, so i can have each character their own set of conversations and assorted by their level?

    Or must i elaborate each of them in separate classes? Thank you.
     
  2. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,716
    List or Dictionary?

    There's no real limit except maybe the size of memory used.
     
    yanuaris likes this.
  3. landon912

    landon912

    Joined:
    Nov 8, 2011
    Posts:
    1,579
    You can add any value into a Dictionary<> or List<>. It works by using their hash, which every object implements.

    You can set up one like this:

    Code (CSharp):
    1. Dictionary<CharacterName, CharacterStats> nameToStats;
    Through this, you can link names(an enum) to their stats(a struct or class) pretty easily.
     
    yanuaris likes this.
  4. yanuaris

    yanuaris

    Joined:
    Oct 16, 2015
    Posts:
    61
    Thank you, this is pretty elaborate so i need to test it myself first!
    Regards!