Пример #1
0
        public GameObject Spawn(string name)
        {
            SubObjectPool pool = null;

            if (!m_pools.ContainsKey(name))
            {
                RegisterNewSubObjectPool(name);
            }
            pool = m_pools[name];
            return(pool.Spawn());
        }
Пример #2
0
        public void Unspawn(GameObject go)
        {
            SubObjectPool pool = null;

            foreach (SubObjectPool p in m_pools.Values)
            {
                if (p.Contains(go))
                {
                    pool = p;
                    break;
                }
            }

            pool.Unspawn(go);
        }
Пример #3
0
        private void RegisterNewSubObjectPool(string name)
        {
            string path = "";

            if (string.IsNullOrEmpty(ResourceDir))
            {
                path = name;
            }
            else
            {
                path = ResourceDir + name;
            }
            GameObject prefabs = Resources.Load <GameObject>(path);

            SubObjectPool pool = new SubObjectPool(prefabs);

            m_pools.Add(name, pool);
        }