unity script list 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: how to create a list in c# unity
List<Datatype> listName = new List<Datatype>();
ex: List<float> myList = new List<float>();