Esempio n. 1
0
        /// <summary>
        /// Add a new pooled prefab at runtime, specifiying its name and amount in the method arguments.
        /// </summary>
        /// <param name="prefab">Prefab to pool.</param>
        /// <param name="name">Name of the pooled object.</param>
        /// <param name="amount">Amount to hold.</param>
        public void Add(GameObject prefab = null, string name = "", int amount = 0)
        {
            PoolLibraryNode node = new PoolLibraryNode(amount, name, prefab);

            m_nodes.Add(node);
            node.Initialize();
        }
Esempio n. 2
0
        /// <summary>
        /// Finds the pooled object based on the string taken as a parameter.
        /// </summary>
        /// <param name="name">Name of the pooled object.</param>
        public PoolLibraryNode Find(string name)
        {
            PoolLibraryNode node = null;

            foreach (PoolLibraryNode n in m_nodes)
            {
                if (n.Name == name)
                {
                    node = n;
                    break;
                }
            }

            return(node);
        }
Esempio n. 3
0
 /// <summary>
 /// Shuts down and removes the specified node.
 /// </summary>
 /// <param name="node">Node to remove.</param>
 public void Remove(PoolLibraryNode node)
 {
     node.Shutdown();
     m_nodes.Remove(node);
 }