Esempio n. 1
0
    public T Spawn <T>(string poolItem, Transform parent) where T : class
    {
        MLPoolBase <T> pool = pools.GetPool(poolItem) as MLPoolBase <T>;

        if (pool == null)
        {
            return(null);
        }

        return(pool.Spawn(parent));
    }
Esempio n. 2
0
    private void DebugInfo()
    {
        MLPoolBase <TestObjectItem> pool = MLPoolManager.Instance.GetPool <TestObjectItem>(POOL_ITEM_NAME);

        GUI.Label(new Rect(400, 10, 200, 32), "Object free num:" + pool.FreeObjectsCount
                  + " used num:" + pool.UsedObjectsCount, labStyle);
        for (int i = 0; i < liveObjects.Count; i++)
        {
            TestObjectItem item = liveObjects[i];
            GUI.Label(new Rect(200, 50 + i * 40, 200, 32), "Name:" + item.name + " num:" + item.num, labStyle);
        }
    }
Esempio n. 3
0
    public void Despawn <T>(string poolItem, T item) where T : class
    {
        MLPoolBase <T> pool = pools.GetPool(poolItem) as MLPoolBase <T>;

        if (pool == null)
        {
            return;
        }

        if (!pool.Despawn(item))
        {
            Debug.LogError("Don't Despawn duplicate Object!");
        }
    }
Esempio n. 4
0
    public void CreatePool <TP, T>(T poolItem = null, int preloadAmount = 10, bool isLimit = true)
        where TP : MLPoolBase <T>
        where T  : class
    {
        Type           type = typeof(TP);
        MLPoolBase <T> pool = pools.CreatePool(type) as MLPoolBase <T>;

        if (pool == null)
        {
            return;
        }

        pool.Init(poolItem, preloadAmount, transform, isLimit);
        pool.CreatePoolItems();

        pools.AddPool(pool.ItemName, pool);
    }