protected int PlayVoiceInternal(SfxData sfx, Action <int> callback) { if (mVolumeSound <= 0f && !sfx.loop) { return(-1); } return(PlaySoundInternal(sfx, false, Vector3.zero, true, mGroupVoice, callback)); }
protected int Play3DAudioInternal(SfxData sfx, Vector3 pos, Action <int> callback) { if (mVolumeSound <= 0f && !sfx.loop) { return(-1); } return(PlaySoundInternal(sfx, true, pos, false, mGroupSound, callback)); }
protected int PlayAudioPitchInternal(SfxData sfx, float pitch, Action <int> callback) { if (mVolumeSound <= 0f && !sfx.loop) { return(-1); } mMasterMixer.SetFloat(FX_PITCH, pitch); return(PlaySoundInternal(sfx, false, Vector3.zero, false, mGroupPitch, callback)); }
public static SfxData GetSfxData(string folder, string sfx) { SfxData data = new SfxData(); data.folder = folder; data.sfx = sfx; data.volume = 1f; data.delay = 0f; data.fadein = 0f; data.loop = false; return(data); }
protected void PlayMusicInternal(SfxData sfx) { if (mCurMusicFolder == sfx.folder && mCurMusicSfx == sfx.sfx) { return; } if (FadeOutStopInternal(mCurMusicId, MUSIC_FADE_DURATION)) { sfx.delay += MUSIC_FADE_DURATION; } mCurMusicFolder = sfx.folder; mCurMusicSfx = sfx.sfx; sfx.loop = true; mCurMusicId = PlaySoundInternal(sfx, false, Vector3.zero, false, mGroupMusic, null); }
private int PlaySoundInternal(SfxData sfx, bool is3D, Vector3 pos, bool isVoice, AudioMixerGroup group, Action <int> callback) { if (string.IsNullOrEmpty(sfx.sfx)) { return(-1); } //Log.dtf("zw", "Play Sound sfxId '{0}' name '{1}' !", sfxId, sfx.sfx); SfxPlayingData data = GetAudioData(); int id = ++mIdGen; data.Init(id, sfx.folder, sfx.sfx, sfx.volume, isVoice, sfx.fadein, Time.unscaledTime + sfx.delay, callback); data.source.transform.position = pos; data.source.spatialBlend = is3D ? 1f : 0f; data.source.volume = sfx.volume; data.source.loop = sfx.loop; data.source.outputAudioMixerGroup = group; if (is3D) { if (m3DSettings != null) { data.source.minDistance = m3DSettings.MinDistance; data.source.maxDistance = m3DSettings.MaxDistance; data.source.SetCustomCurve(AudioSourceCurveType.CustomRolloff, m3DSettings.RollOffCurve); data.source.rolloffMode = AudioRolloffMode.Custom; } else { data.source.minDistance = 1f; data.source.maxDistance = 1000f; data.source.rolloffMode = AudioRolloffMode.Logarithmic; } } if (isVoice) { mVoiceList.Add(data); if (mVoiceList.Count == 1) { mVolumeMusicLimitFrom = mVolumeMusicLimit; mVolumeMusicLimitTo = 0.2f; mVolumeMusicLimitDuration = 1f / 0.5f; mVolumeMusicLimitTimer = 0f; } } mLoadingList.Add(data.id, data); data.Load(); return(data.id); }