Пример #1
0
        public override void SetAsset(Object unityObj, AssetBundleInstance refAssetBundle)
        {
            if (unityObj)
            {
                var prefab      = unityObj as GameObject;
                var cacheConfig = prefab.GetComponent <PoolCacheGO>();
                if (cacheConfig)
                {
                    if (m_pool != null)
                    {
                        throw new Exception("Pool is created!");
                    }

                    m_pool = new AssetPool(prefab.name, cacheConfig.PreferCount, cacheConfig.MaxCount, this);
                }

                m_autoRecyclePrefab = prefab.GetComponent <AutoRecycle>();

#if UNITY_EDITOR
                ChildCountRecursive(prefab.transform);
                m_transformCount++;
#endif
            }

            base.SetAsset(unityObj, refAssetBundle);
        }
Пример #2
0
        public void InitPool(string name, int prefer, int max)
        {
            if (m_pool != null)
            {
                throw new Exception("Pool is created!");
            }

            var go = UnityObject as GameObject;

            if (!go.GetComponent <PoolCacheGO>())
            {
                throw new Exception($"{go.name} need add PoolCacheGO component.");
            }

            m_pool = new AssetPool(name, prefer, max, this);
            m_pool.WarmUp();
        }
Пример #3
0
 public override void Destroy()
 {
     base.Destroy();
     m_pool?.Dispose();
     m_pool = null;
 }