コード例 #1
0
 /// <summary>
 /// Remove audio from dictionary
 /// </summary>
 /// <param name="item"></param>
 public void RemoveAudio(GJ_AudioItem item)
 {
     if (m_audios.ContainsValue(item))
     {
         m_audios.Remove(item.m_itemKeyInDictionary);
     }
 }
コード例 #2
0
        /// <summary>
        /// Creates a new audio items and play its clip
        /// </summary>
        /// <param name="type"></param>
        /// <param name="clip"></param>
        /// <param name="source"></param>
        /// <param name="name"></param>
        /// <param name="inLoop"></param>
        /// <param name="volume"></param>
        public void CreateItemAndPlay(bool _addIt = true, string _key = "audio", GJ_AudioSetup.AudioTypes _type = GJ_AudioSetup.AudioTypes.SFX, AudioClip _clip = null, AudioSource _source = null, bool _inLoop = false, float _volume = 1f)
        {
            if (_source == null)
            {
                _source = m_sources[(int)_type];
            }

            GJ_AudioItem audio = CreateItem(_addIt, _key, _type, _clip, _source, _inLoop, _volume * m_mainVolume);

            audio.Play();
        }
コード例 #3
0
 /// <summary>
 /// Play one shot based on key
 /// </summary>
 /// <param name="key"></param>
 public void PlayOneShotAudioByKey(string key)
 {
     if (m_audios.ContainsKey(key))
     {
         GJ_AudioItem audio = m_audios[key];
         audio.PlayOneShot();
     }
     else
     {
         Debug.LogError("[Error] AudioManager doesn't contain " + key + " in the dictionary.");
     }
 }
コード例 #4
0
 /// <summary>
 /// Add audio item to dictionary
 /// </summary>
 /// <param name="item"></param>
 public void AddAudio(GJ_AudioItem item)
 {
     if (!m_audios.ContainsValue(item))
     {
         m_audios.Add(item.m_itemKeyInDictionary, item);
     }
     else if (m_forceSameKey)
     {
         item.m_itemKeyInDictionary += "(ForzedClone)";
         AddAudio(item);
     }
 }
コード例 #5
0
        /// <summary>
        /// Creates a new AudioItem and returns it so can be used
        /// </summary>
        /// <param name="type"></param>
        /// <param name="clip"></param>
        /// <param name="source"></param>
        /// <param name="name"></param>
        /// <param name="inLoop"></param>
        /// <param name="volume"></param>
        /// <returns></returns>
        public GJ_AudioItem CreateItem(bool _addIt = true, string _key = "audio", GJ_AudioSetup.AudioTypes _type = GJ_AudioSetup.AudioTypes.SFX, AudioClip _clip = null, AudioSource _source = null, bool _inLoop = false, float _volume = 1f)
        {
            if (_source == null)
            {
                _source = m_sources[(int)_type];
            }

            GJ_AudioItem audio = new GJ_AudioItem(_key, _type, _clip, _source, _inLoop, _volume * m_mainVolume);

            if (_addIt)
            {
                AddAudio(audio);
            }

            return(audio);
        }
コード例 #6
0
 /// <summary>
 /// Add audio to dictionary and plays its audioclip
 /// </summary>
 /// <param name="item"></param>
 public void AddAudioAndPlay(GJ_AudioItem item)
 {
     AddAudio(item);
     item.Play();
 }