Esempio n. 1
0
 void InitTemplatePool()
 {
     if (m_Pool == null)
     {
         m_Pool = new GameObjectPool(OnPoolGet, OnPoolRealse);
         for (int i = 0; i < templates.Length; i++)
         {
             m_Pool.Add(i, templates[i]);
         }
     }
 }
Esempio n. 2
0
    protected override void OnDebugAgentRemoved(GameEntity entity)
    {
        if (!DebuggerLinks.ContainsKey(entity))
        {
            return;
        }

        var container = DebuggerLinks[entity];

        container.gameObject.SetActive(false);
        container.transform.SetParent(transform, false);

        GameObjectPool.Add(container.gameObject);
        DebuggerLinks.Remove(entity);
    }
    public bool StoreObject(GameObject obj, string path)
    {
        bool success = true;

        string         key  = path;
        GameObjectPool pool = null;

        //不在缓存池里面,创建新的添加
        if (!pools.ContainsKey(key))
        {
            pool = new GameObjectPool();
            pool.Add(obj);
            pool.maxIdleTime = maxIdleTime;
            pools.Add(key, pool);
        }
        //已经在缓存池里面,直接取出
        pools.TryGetValue(key, out pool);
        pool.Add(obj);
        pool.maxIdleTime = maxIdleTime;

        return(success);
    }