コード例 #1
0
    public virtual void PushObject <T>(JPoolObject obj)
    {
        obj.OnReturnToPool();
        Type type = typeof(T);

        pool.Add(type, obj);
    }
コード例 #2
0
    public void ReturnToPool(string key, JPoolObject poolObject)
    {
        foundedQueue = null;
        if (!pool.TryGetValue(key, out foundedQueue))
        {
            foundedQueue = new Queue <JPoolObject>();
            pool.Add(key, foundedQueue);
        }

        poolObject.gameObject.SetActive(false);
        poolObject.sleepTime = Time.realtimeSinceStartup;
        poolObject.OnReturnToPool();
        foundedQueue.Enqueue(poolObject);
    }