static void FadeSourcesTo(float to, float duration, bool ignoreTimeScale, FadeBehaviour onCompleteBehaviour, TweenCallback onComplete) { int len = audioGroups.Length; for (int i = 0; i < len; ++i) { audioGroups[i].FadeSourcesTo(to, duration, ignoreTimeScale, onCompleteBehaviour, onComplete); } }
// Use this for initialization void Start() { boredom = boredomMax; gameRunning = true; pig = (PigBehaviour)FindObjectOfType(typeof(PigBehaviour)); tickIndex = 0; fade = this.GetComponent <FadeBehaviour>(); fade.FadeIn(); }
internal void FadeSourcesTo(float to, float duration, bool ignoreTimeScale, FadeBehaviour onCompleteBehaviour, TweenCallback onComplete) { int len = sources.Count; for (int i = 0; i < len; ++i) { DeAudioSource src = sources[i]; if (!src.isPlaying || src.isFadingOut) { continue; // Ignore sources that are fading to 0 or that are not playing at all } sources[i].FadeTo(to, duration, ignoreTimeScale, onCompleteBehaviour, onComplete); } }
private IEnumerator loadNextLevel() { yield return new WaitForSeconds(3f); fade = this.GetComponent<FadeBehaviour>(); fade.FadeOut(); yield return new WaitForSeconds(2f); string nextLevel = levelList[0]; for (int i = 0; i < levelList.Length - 1; i++) { if (levelList[i].Equals(Application.loadedLevelName)) { nextLevel = levelList[i+1]; } } Application.LoadLevel(nextLevel); }
internal void FadeTo(float to, float duration, bool ignoreTimeScale, FadeBehaviour onCompleteBehaviour, TweenCallback onComplete) { _fadeTween.Kill(); _fadeTween = DOTween.To(() => volume, x => volume = x, to, duration) .SetTarget(this).SetUpdate(ignoreTimeScale).SetEase(DeAudioManager.I.fadeEase); switch (onCompleteBehaviour) { case FadeBehaviour.Stop: _fadeTween.OnStepComplete(Stop); break; case FadeBehaviour.Pause: _fadeTween.OnStepComplete(Pause); break; } if (onComplete != null) { _fadeTween.OnComplete(onComplete); } }
private IEnumerator loadNextLevel() { yield return(new WaitForSeconds(3f)); fade = this.GetComponent <FadeBehaviour>(); fade.FadeOut(); yield return(new WaitForSeconds(2f)); string nextLevel = levelList[0]; for (int i = 0; i < levelList.Length - 1; i++) { if (levelList[i].Equals(Application.loadedLevelName)) { nextLevel = levelList[i + 1]; } } Application.LoadLevel(nextLevel); }
internal void FadeTo(float to, float duration, bool ignoreTimeScale, FadeBehaviour onCompleteBehaviour, TweenCallback onComplete) { if (to <= 0) { to = 0; } else { float maxScaledVolume = 1 / targetVolume / audioGroup.fooVolume / DeAudioManager.globalVolume; if (to > maxScaledVolume) { to = maxScaledVolume; } } _fadeTween.Kill(); _fadeTween = DOTween.To(() => unscaledVolume, x => volume = x, to, duration) .SetTarget(this).SetUpdate(ignoreTimeScale).SetEase(DeAudioManager.I.fadeEase); if (to <= 0) { isFadingOut = true; } switch (onCompleteBehaviour) { case FadeBehaviour.Stop: _fadeTween.OnStepComplete(OnFadeToInternalComplete_Stop); break; case FadeBehaviour.Pause: _fadeTween.OnStepComplete(OnFadeToInternalComplete_Pause); break; default: _fadeTween.OnStepComplete(OnFadeToInternalComplete_Default); break; } if (onComplete != null) { _fadeTween.OnComplete(onComplete); } }
// places an asset in the arena at a random location and with a random orientation void placeAsset() { // randomise the location within x and z boundaries float x = Random.Range(-500, 500); float z = Random.Range(-500, 500); Vector3 location = new Vector3(x, 50f, z); // randomise the asset to be placed int assetIndex = Mathf.RoundToInt(Random.Range(0, getAmountOfAssets())); GameObject asset = assets[assetIndex]; fading = asset.GetComponent <FadeBehaviour>(); // How long before the asset is refreshed float assetTimer = Random.Range(1, 15); // instantiate the asset GameObject currentAsset = (GameObject)Instantiate(asset, location, Quaternion.identity); //Destroy (currentAsset, assetTimer); //Invoke ("fadeOut", assetTimer); fading.queFadeOut(assetTimer); Debug.Log("invoking fade-out"); Invoke("placeAsset", assetTimer); }
public FadeBehaviourWrapper(FadeBehaviour fadeBehaviour) { this.fadeBehaviour = fadeBehaviour; }
/// <summary>Fades out the volume of each source in this group (not this group's volume)</summary> public void FadeSourcesOut(float duration = 1.5f, bool ignoreTimeScale = true, FadeBehaviour onCompleteBehaviour = FadeBehaviour.Stop) { FadeSourcesTo(0, duration, ignoreTimeScale, onCompleteBehaviour, null); }
/// <summary>Fades out this group's volume</summary> public void FadeOut(float duration = 1.5f, bool ignoreTimeScale = true, FadeBehaviour onCompleteBehaviour = FadeBehaviour.Stop, TweenCallback onComplete = null) { FadeTo(0, duration, ignoreTimeScale, onCompleteBehaviour, onComplete); }
public static FadeBehaviourWrapper Wrap(FadeBehaviour fadeBehaviour) => new FadeBehaviourWrapper { FadeBehaviour = fadeBehaviour };
/// <summary>Fades out the volume of each source in the given group (not the given group's volume)</summary> public static void FadeSourcesOut(DeAudioGroupId groupId, float duration = 1.5f, bool ignoreTimeScale = true, FadeBehaviour onCompleteBehaviour = FadeBehaviour.Stop, TweenCallback onComplete = null) { FadeSourcesTo(groupId, 0, duration, ignoreTimeScale, onCompleteBehaviour, onComplete); }
/// <summary> /// Fades out then stops all sources in this group, while starting the given <see cref="DeAudioClipData"/> with a fade-in effect. /// <para>Returns the <see cref="DeAudioSource"/> instance used to play, or NULL if the clip couldn't be played</para> /// </summary> public DeAudioSource Crossfade(DeAudioClipData clipData, float fadeDuration = 1.5f, bool ignoreTimeScale = true, FadeBehaviour onfadeOutBehaviour = FadeBehaviour.Stop, TweenCallback onComplete = null) { return(Crossfade(clipData.clip, clipData.volume, clipData.pitch, clipData.loop, fadeDuration, ignoreTimeScale, onfadeOutBehaviour, onComplete)); }
// Use this for initialization void Start() { boredom = boredomMax; gameRunning = true; pig = (PigBehaviour) FindObjectOfType(typeof(PigBehaviour)); tickIndex = 0; fade = this.GetComponent<FadeBehaviour>(); fade.FadeIn(); }
static void FadeSourcesTo(DeAudioGroupId groupId, float to, float duration, bool ignoreTimeScale, FadeBehaviour onCompleteBehaviour, TweenCallback onComplete) { DeAudioGroup group = GetAudioGroup(groupId); if (group != null) { group.FadeSourcesTo(to, duration, ignoreTimeScale, onCompleteBehaviour, onComplete); } }
/// <summary> /// Fades out then stops all sources in the given group, while starting the given clip with a fade-in effect. /// <para>Returns the <see cref="DeAudioSource"/> instance used to play, or NULL if the clip couldn't be played</para> /// </summary> public static DeAudioSource Crossfade(DeAudioGroupId groupId, AudioClip clip, float volume = 1, float pitch = 1, bool loop = false, float fadeDuration = 1.5f, bool ignoreTimeScale = true, FadeBehaviour onfadeOutBehaviour = FadeBehaviour.Stop, TweenCallback onComplete = null) { DeAudioGroup group = GetAudioGroup(groupId); if (group == null) { Debug.LogWarning(LogPrefix + "Crossfade can't happend and clip can't be played because no group with the given groupId (" + groupId + ") was created"); return(null); } return(group.Crossfade(clip, volume, pitch, loop, fadeDuration, ignoreTimeScale, onfadeOutBehaviour, onComplete)); }
static void FadeTo(AudioClip clip, float to, float duration, bool ignoreTimeScale, FadeBehaviour onCompleteBehaviour, TweenCallback onComplete) { int len = audioGroups.Length; for (int i = 0; i < len; ++i) { DeAudioGroup group = audioGroups[i]; int slen = group.sources.Count; for (int c = 0; c < slen; c++) { DeAudioSource s = group.sources[c]; if (s.clip == clip) { s.FadeTo(to, duration, ignoreTimeScale, onCompleteBehaviour, onComplete); } } } }
/// <summary> /// Fades out then stops all sources in this group, while starting the given clip with a fade-in effect. /// <para>Returns the <see cref="DeAudioSource"/> instance used to play, or NULL if the clip couldn't be played</para> /// </summary> public DeAudioSource Crossfade(AudioClip clip, float volume = 1, float pitch = 1, bool loop = false, float fadeDuration = 1.5f, bool ignoreTimeScale = true, FadeBehaviour onfadeOutBehaviour = FadeBehaviour.Stop, TweenCallback onComplete = null) { FadeSourcesTo(0, fadeDuration, ignoreTimeScale, onfadeOutBehaviour, null); DeAudioSource s = Play(clip, volume, pitch, loop); if (s != null) { s.FadeFrom(0, fadeDuration, ignoreTimeScale, onComplete); } return(s); }
void fadeOut(FadeBehaviour fading) { fading.startFadeOut(); }