Пример #1
0
 public static GameObject InstantiateGameObject(GameObject go, PoolType pType)
 {
     if (!m_PoolDict.ContainsKey(pType))
     {
         m_PoolDict.Add(pType, new Dictionary <string, PoolSpawn>());
     }
     if (!m_PoolDict[pType].ContainsKey(go.name))
     {
         var pool = new PoolSpawn(go);
         m_PoolDict[pType].Add(go.name, pool);
     }
     return(m_PoolDict[pType][go.name].GetGameObject());
 }
Пример #2
0
    public static GameObject InstantiateGameObject(string path, PoolType pType)
    {
        GameObject go = ResourceManager.Load <GameObject>(path);

        if (!m_PoolDict.ContainsKey(pType))
        {
            m_PoolDict.Add(pType, new Dictionary <string, PoolSpawn>());
        }
        try
        {
            if (!m_PoolDict[pType].ContainsKey(go.name))
            {
                var pool = new PoolSpawn(go);
                m_PoolDict[pType].Add(go.name, pool);
            }
        }
        catch (System.Exception)
        {
            Debug.LogError("获取物体失败,路径:" + path);
        }
        return(m_PoolDict[pType][go.name].GetGameObject());
    }