Create group people, Select one or more at random.

I’m trying to create a group of items with certain attributes and then select one item and show their attributes. The “group” can be a list, array, class, anything (whatever is the absolute easiest to work with so long as I can add and remove items at will).

For the sake of argument, say I have four people along with their age and weight.

Bob, 25, 150;
Mike, 33, 175;
Jenny, 18, 110;
Susan, 20, 115;

I simply don’t know how to create the class or list (etc.) that includes these items and then select a person and display their proper age and weight.

I’ve been searching high and low and so far, I’ve tried everything I know and can’t quite get any of it to work.

This will work for you (I added a UI.Dropdown list)

using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System.Collections.Generic;

[System.Serializable]
public class Person
{
    public int id;
    public string name;
    public int age;
    public float weight;

    public Person(string _name, int _age, float _weight)
    {
        name = _name;
        age = _age;
        weight = _weight;
    }
}

public class PersonIndexer : MonoBehaviour
{
    public List<Person> people = new List<Person>();
    public Dropdown dropDown;
    
    private Text text;

    void Start()
    {
        AddPerson("Bob", 25, 150);
        AddPerson("Mike", 33, 175);
        AddPerson("Jenny", 18, 110);
        AddPerson("Susan", 20, 115);
        
        if (dropDown != null)
        {
            text = dropDown.gameObject.GetComponentsInChildren<Text>()[0];
            dropDown.options.Clear();
            for (int i = 0; i < people.Count; i++)
            {
                dropDown.options.Add(new Dropdown.OptionData(string.Format("Name: {0}, Age: {1} Weight: {2}", people<em>.name, people_.age, people*.weight)));*_</em>

}
text.text = dropDown.options[0].text;
dropDown.value = 0;
}
}

void AddPerson(string _name, int _age, float _weight)
{
Person person = new Person(_name, _age, _weight);
people.Add(person);
}
}