/// <summary> /// Completes the life of the agent and pools or destroys it. /// </summary> /// <param name="agent">Agent.</param> public static void EndLife(LSAgent agent) { if (agent.CachedGameObject != null) { agent.CachedGameObject.SetActive(false); } agent._EndLife(); if (agent.TypeIndex != UNREGISTERED_TYPE_INDEX) { AgentController.CacheAgent(agent); } else { //This agent was not registered for pooling. Let's destroy it GameObject.Destroy(agent); } }