/// <summary> /// 加载内部资源 /// </summary> public override void LoadResource() { if (m_FileName.Length == 0) { this.Destroy(); CommonObjectPools.Despawn(this); return; } Object res = ResourceLoaderManager.Instance.GetResource(m_FileName); if (res == null) { ResourceManager.Instance.AddAsync(m_FileName, eResType.SOUND, delegate(sResLoadResult info) { if (!m_Active) { this.Destroy(); CommonObjectPools.Despawn(this); return; } OnLoadComplete(); } ); } else { OnLoadComplete(); } }
public void RemoveBGSound(BackgroundSound sound) { if (sound != null) { sound.Stop(); sound.Destroy(); CommonObjectPools.Despawn(sound); m_ListBGAudio.Remove(sound); } }
/**统一销毁接口*/ static public void Destroy(DropPhysxObj obj) { if (obj == null) { return; } obj.Release(); CommonObjectPools.Despawn(obj); }
public void StopSoundEffect(SoundBase sound) { if (sound == null) { return; } sound.Stop(); sound.Destroy(); CommonObjectPools.Despawn(sound); }
public void ClearBGSound() { for (int i = 0; i < m_ListBGAudio.Count; ++i) { SoundBase sound = m_ListBGAudio[i]; sound.Stop(); sound.Destroy(); CommonObjectPools.Despawn(sound); } m_ListBGAudio.Clear(); }
public override void OnLoadComplete() { AudioSource aSrc = AudioSourcePools.instance.SpawnByFile(m_FileName, m_Position, m_ParentNode); if (aSrc != null && aSrc.clip != null) { aSrc.pitch = 1; aSrc.volume = SoundManager.Instance.EffectSoundVolume; aSrc.loop = m_PlayCount > 1 ? true : false; aSrc.minDistance = m_MinDistance; aSrc.maxDistance = m_MaxDistance; if (m_IsPlay) { aSrc.Play(); } else { aSrc.Stop(); } AutoDestroyAudio component = aSrc.gameObject.GetComponent <AutoDestroyAudio>(); if (component == null) { component = aSrc.gameObject.AddComponent <AutoDestroyAudio>(); } component.PlayCount = m_PlayCount; component.DestroyCallback = OnComponentDestroy; m_SoundSource = aSrc; } else { this.Destroy(); CommonObjectPools.Despawn(this); return; } }
/// <summary> /// 组件自动销毁回调 /// </summary> private void OnComponentDestroy() { m_Active = false; this.Destroy(); CommonObjectPools.Despawn(this); }