public bool TrySpawnAgent(AIUnit unit, out AIAgent newAgent) { AIAgent agentPrefab = unit.Data.childPrefab; Debug.Assert(agentPrefab != null, "unit data doesn't have a agent prefab"); if (unit.children.Count >= (int)unit.Data.maxSize) { newAgent = null; return(false); } else { newAgent = LeanPool.Spawn(agentPrefab, spawningPosition, Quaternion.identity); unit.AddNewChild(newAgent); return(true); } }