The null reference exception comes from either the SortedList being null or the UnitInfo component being null.
Has your SortedList been initialized?
UnitInfos = new SortedList();
Does every tagged object have a UnityInfo component? otherwise you can check this by writing
if (g.GetComponent() != null)
UnitInfos.Add(g.GetComponent().Reaction, g);
↧