public override GameObject GetObjectToReplace(GameObjectPool pool, List <GameObject> activeInstances, Stack <GameObject> inactiveInstances) { int num = int.MaxValue; GameObject gameObject = null; for (int i = 0; i < activeInstances.Count; i++) { PriorityComponent component = activeInstances[i].GetComponent <PriorityComponent>(); if (component != null) { int priority = component.Priority; if (priority < num) { num = priority; gameObject = activeInstances[i]; } } else { Logger.LogFatal(activeInstances[i], "Attempting to replace pooled instance based on priority, however the game object or prefab is missing the required PooledPriorityComponent!", Logger.TagFlags.CORE | Logger.TagFlags.MEMORY); } } if (gameObject != null) { gameObject.SendMessage("OnStolenFromPool", SendMessageOptions.DontRequireReceiver); PriorityComponent component = gameObject.GetComponent <PriorityComponent>(); if (component != null) { component.Reset(); } } return(gameObject); }