/// <summary> /// Internal coroutine used for repeated play without end /// </summary> /// <param name="position"></param> /// <param name="feedbacksIntensity"></param> /// <returns></returns> protected virtual IEnumerator InfinitePlay(Vector3 position, float feedbacksIntensity = 1.0f) { while (true) { _lastPlayTimestamp = FeedbackTime; if (Timing.Sequence == null) { CustomPlayFeedback(position, feedbacksIntensity); if (Timing.TimescaleMode == TimescaleModes.Scaled) { yield return(MMFeedbacksCoroutine.WaitFor(Timing.DelayBetweenRepeats)); } else { yield return(MMFeedbacksCoroutine.WaitForUnscaled(Timing.DelayBetweenRepeats)); } } else { _sequenceCoroutine = StartCoroutine(SequenceCoroutine(position, feedbacksIntensity)); float delay = ApplyTimeMultiplier(Timing.DelayBetweenRepeats) + Timing.Sequence.Length; if (Timing.TimescaleMode == TimescaleModes.Scaled) { yield return(MMFeedbacksCoroutine.WaitFor(delay)); } else { yield return(MMFeedbacksCoroutine.WaitForUnscaled(delay)); } } } }
protected override IEnumerator HandleInitialDelayCo(Vector3 position, float feedbacksIntensity, bool forceRevert = false) { IsPlaying = true; yield return(MMFeedbacksCoroutine.WaitForUnscaled(InitialDelay)); PreparePlay(position, feedbacksIntensity, forceRevert); }
/// <summary> /// An IEnumerator used to wait for the duration of the pause, on scaled or unscaled time /// </summary> /// <returns></returns> protected virtual IEnumerator PauseWait() { if (Timing.TimescaleMode == TimescaleModes.Scaled) { return(MMFeedbacksCoroutine.WaitFor(PauseDuration)); } else { return(MMFeedbacksCoroutine.WaitForUnscaled(PauseDuration)); } }
protected virtual IEnumerator FrameOnePlayCo(Vector3 position, float feedbacksIntensity, bool forceRevert = false) { yield return(null); _startTime = Time.unscaledTime; _lastStartAt = _startTime; IsPlaying = true; yield return(MMFeedbacksCoroutine.WaitForUnscaled(InitialDelay)); PreparePlay(position, feedbacksIntensity, forceRevert); }
/// <summary> /// Reveals characters one at a time /// </summary> /// <returns></returns> protected virtual IEnumerator RevealCharacters() { float startTime = (Timing.TimescaleMode == TimescaleModes.Scaled) ? Time.time : Time.unscaledTime; int totalCharacters = _richTextLength; int visibleCharacters = 0; float lastCharAt = 0f; IsPlaying = true; while (visibleCharacters <= totalCharacters) { float deltaTime = (Timing.TimescaleMode == TimescaleModes.Scaled) ? Time.deltaTime : Time.unscaledDeltaTime; float time = (Timing.TimescaleMode == TimescaleModes.Scaled) ? Time.time : Time.unscaledTime; if (time - lastCharAt < IntervalBetweenReveals) { yield return(null); } TargetTMPText.maxVisibleCharacters = visibleCharacters; visibleCharacters++; lastCharAt = time; // we adjust our delay float delay = 0f; if (DurationMode == DurationModes.Interval) { _delay = Mathf.Max(IntervalBetweenReveals, deltaTime); delay = _delay - deltaTime; } else { int remainingCharacters = totalCharacters - visibleCharacters; float elapsedTime = time - startTime; if (remainingCharacters != 0) { _delay = (RevealDuration - elapsedTime) / remainingCharacters; } delay = _delay - deltaTime; } if (Timing.TimescaleMode == TimescaleModes.Scaled) { yield return(MMFeedbacksCoroutine.WaitFor(delay)); } else { yield return(MMFeedbacksCoroutine.WaitForUnscaled(delay)); } } TargetTMPText.maxVisibleCharacters = _richTextLength; IsPlaying = false; }
/// <summary> /// An internal coroutine delaying the initial play of the feedback /// </summary> /// <param name="position"></param> /// <param name="feedbacksIntensity"></param> /// <returns></returns> protected virtual IEnumerator PlayCoroutine(Vector3 position, float feedbacksIntensity = 1.0f) { if (Timing.TimescaleMode == TimescaleModes.Scaled) { yield return(MMFeedbacksCoroutine.WaitFor(Timing.InitialDelay)); } else { yield return(MMFeedbacksCoroutine.WaitForUnscaled(Timing.InitialDelay)); } _lastPlayTimestamp = FeedbackTime; RegularPlay(position, feedbacksIntensity); }
public virtual IEnumerator Flicker(Renderer renderer, int materialIndex, Color initialColor, Color flickerColor, float flickerSpeed, float flickerDuration) { if (renderer == null) { yield break; } if (!_propertiesFound[materialIndex]) { yield break; } if (initialColor == flickerColor) { yield break; } float flickerStop = FeedbackTime + flickerDuration; IsPlaying = true; while (FeedbackTime < flickerStop) { SetColor(materialIndex, flickerColor); if (Timing.TimescaleMode == TimescaleModes.Scaled) { yield return(MMFeedbacksCoroutine.WaitFor(flickerSpeed)); } else { yield return(MMFeedbacksCoroutine.WaitForUnscaled(flickerSpeed)); } SetColor(materialIndex, initialColor); if (Timing.TimescaleMode == TimescaleModes.Scaled) { yield return(MMFeedbacksCoroutine.WaitFor(flickerSpeed)); } else { yield return(MMFeedbacksCoroutine.WaitForUnscaled(flickerSpeed)); } } SetColor(materialIndex, initialColor); IsPlaying = false; }
/// <summary> /// Reveals words one at a time /// </summary> /// <returns></returns> protected virtual IEnumerator RevealWords() { int totalWords = TargetTMPText.textInfo.wordCount; int visibleWords = 0; while (visibleWords <= totalWords) { TargetTMPText.maxVisibleWords = visibleWords; visibleWords++; if (Timing.TimescaleMode == TimescaleModes.Scaled) { yield return(MMFeedbacksCoroutine.WaitFor(_delay)); } else { yield return(MMFeedbacksCoroutine.WaitForUnscaled(_delay)); } } }
/// <summary> /// Reveals characters one at a time /// </summary> /// <returns></returns> protected virtual IEnumerator RevealCharacters() { int totalCharacters = TargetTMPText.text.Length; int visibleCharacters = 0; while (visibleCharacters <= totalCharacters) { TargetTMPText.maxVisibleCharacters = visibleCharacters; visibleCharacters++; if (Timing.TimescaleMode == TimescaleModes.Scaled) { yield return(MMFeedbacksCoroutine.WaitFor(_delay)); } else { yield return(MMFeedbacksCoroutine.WaitForUnscaled(_delay)); } } }
/// <summary> /// Reveals lines one at a time /// </summary> /// <returns></returns> protected virtual IEnumerator RevealLines() { int totalLines = TargetTMPText.textInfo.lineCount; int visibleLines = 0; IsPlaying = true; while (visibleLines <= totalLines) { TargetTMPText.maxVisibleLines = visibleLines; visibleLines++; if (Timing.TimescaleMode == TimescaleModes.Scaled) { yield return(MMFeedbacksCoroutine.WaitFor(_delay)); } else { yield return(MMFeedbacksCoroutine.WaitForUnscaled(_delay)); } } IsPlaying = false; }