示例#1
0
        /// <summary>
        /// Expands the pool by creating another object and adding it to the end
        /// </summary>
        /// <returns>Reference to the object that was created</returns>
        private void ExpandPool()
        {
            GameObject newGameobject = Object.Instantiate(Template);
            T          newPoolable   = newGameobject.GetComponent <T>();

            // Poolable Objects need a reference to the object pool irrelevant of type
            // this interface defines the return method
            newPoolable.ParentPool = this;

            newGameobject.transform.SetParent(PoolParent, false);

            if (AllowStartOnExpandedObjects)
            {
                DelayedAction.AfterFrame(() => newPoolable.InUse = false);
            }
            else
            {
                newPoolable.InUse = false;
            }

            Available.Push(newPoolable);
            Pool.Add(newPoolable);
            newPoolable.PoolExpanded();
            OnExpand?.Invoke(newPoolable);
        }
示例#2
0
 public static void SetFloat(AudioMixer audioMixer, string propertyName, float volume)
 {
     if (Time.frameCount == 0)
     {
         DelayedAction.AfterFrame(() => SetFloat(audioMixer, propertyName, volume));
         return;
     }
     audioMixer.SetFloat(propertyName, volume);
 }