using lists in unity code example
Example 1: how to create a public list unity
void Start ()
{
public List<BadGuy> badguys = new List<BadGuy>();
badguys.Add( new BadGuy("Harvey", 50));
badguys.Add( new BadGuy("Magneto", 100));
badguys.Add( new BadGuy("Pip", 5));
badguys.Sort();
foreach(BadGuy guy in badguys)
{
print (guy.name + " " + guy.power);
}
badguys.Clear();
}
Example 2: unity list
GameObject Obj;
List<GameObject> Objects = new List<GameObject>();
Objects.Add(Obj);
Example 3: unity list
GameObject Obj;
List<GameObject> Objects = new List<GameObject>();
Objects.Add(Obj);
Objects.remove(Obj);,
Objects.Insert(0,Obj);
Objects.RemoveAt(0);