void AddUnit() { Barracks script = barracks.GetComponent <Barracks>(); if (isMelee) { script.AddUnitMeleeCount(1); } else if (!isMelee) { script.AddUnitRangedCount(1); } print("unit added"); }