예제 #1
0
        internal void Stop(SoundObject soundObject)
        {
            int index = m_Playing.IndexOf(soundObject);

            m_Playing[index] = null;
            Return(soundObject);
        }
예제 #2
0
 void Return(SoundObject obj)
 {
     if (m_Stack.Count < MaxPoolCount)
     {
         m_Stack.Push(obj);
     }
     else
     {
         obj.Destroy();
     }
 }
예제 #3
0
 public void ReservePool(int count = -1)
 {
     if (count < 0)
     {
         count = MaxPoolCount;
     }
     for (int i = m_TotalCount; i < count; i++)
     {
         m_Stack.Push(SoundObject.Create(this, m_Root));
         m_TotalCount++;
     }
 }
예제 #4
0
 SoundObject Borrow(bool force)
 {
     if (m_Stack.Count > 0)
     {
         return(m_Stack.Pop());
     }
     else if (m_TotalCount < MaxPoolCount)
     {
         m_TotalCount++;
         return(SoundObject.Create(this, m_Root));
     }
     else if (force)
     {
         return(SoundObject.Create(this, m_Root));
     }
     return(null);
 }
예제 #5
0
        public static SoundObject Create(PlayingList playingList, Transform parent)
        {
            SoundObject ret = new SoundObject();
            var         obj = new GameObject(nameof(SoundObject));

            obj.hideFlags = parent.hideFlags;
            obj.transform.SetParent(parent);
            var source = obj.AddComponent <AudioSource>();

            source.playOnAwake   = false;
            ret.m_PlayingList    = playingList;
            ret.m_Object         = obj;
            ret.m_Source         = source;
            ret.m_TransformCache = source.transform;
            obj.SetActive(false);
            return(ret);
        }