Exemple #1
0
        public static void ClearPool <T>(T instance)
            where T : class
        {
            if (instance == null)
            {
                Debug.LogError("[Pool:ClearPool()] -> Instance cant be null.");
                return;
            }

            if (typeof(T).IsSameOrSubclass(typeof(Component)))
            {
                PoolGameObject pool = GetPool((instance as Component).gameObject);
                pool?.Clear();
            }
            else if (typeof(T).IsSameOrSubclass(typeof(GameObject)))
            {
                PoolGameObject pool = GetPool(instance as GameObject);
                pool?.Clear();
            }
            else
            {
                PoolObject <T> .Instance?.Clear();
            }
        }