예제 #1
0
    public PoolableObject GetObject()
    {
        for (int i = 0; i < m_Pool.Count; i++)
        {
            if (m_Pool[i].CanUse())
            {
                return(m_Pool[i]);
            }
        }
        PoolableObject _poolableObject = Instantiate(m_Prefab).GetComponent <PoolableObject>();    //Getcompent poolableobject;

        _poolableObject.Load();
        _poolableObject.PoolObject();                                                             //Pool the object;
        m_Pool.Add(_poolableObject);
        return(_poolableObject);
    }
예제 #2
0
 private void MakePool(int length, Transform parent)
 {
     m_Pool = new List <PoolableObject>();
     for (int i = 0; i < length; i++)
     {
         PoolableObject _poolableObject = null;
         if (parent == null)
         {
             _poolableObject = Instantiate(m_Prefab).GetComponent <PoolableObject>();   //Getcompent poolableobject;
         }
         else
         {
             _poolableObject = Instantiate(m_Prefab, parent).GetComponent <PoolableObject>();
         }
         _poolableObject.Load();
         _poolableObject.HideOjbect();                                                            //Pool the object;
         m_Pool.Add(_poolableObject);                                                             //Add to the list;
     }
 }