unity Liat<> 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: dictionary in c# unity
public class ScriptA : MonoBehaviour{
public Dictionary<string, GameObject> dictio = new Dictionary<string, GameObject>();
}