void Start() { // Set text TMP_Text textMesh = GetComponent <TMP_Text>(); textMesh.text = "DETERMINATION"; CharTweener tweener = textMesh.GetCharTweener(); for (int i = 0; i < tweener.CharacterCount; i++) { // Move characters in a circle Tween circleTween = tweener.DOMoveCircle(i, 0.05f, 0.5f) .SetLoops(-1, LoopType.Restart); // Fade character color between yellow and white Tween colorTween = tweener.DOColor(i, Color.yellow, 0.5f) .SetLoops(-1, LoopType.Yoyo); // Offset animations based on character index in string float timeOffset = (float)i / tweener.CharacterCount; circleTween.fullPosition = timeOffset; colorTween.fullPosition = timeOffset; } }
// CharTweener black magic happens here. private IEnumerator AnimateText() { CharTweener charTweener = text.GetCharTweener(); Tween[] resets = GetResetTweens(charTweener); foreach (KeyValuePair <TextEffect, MatchCollection> pair in effectSubstrings) { foreach (Match match in pair.Value) { for (int i = match.Index; i < (match.Index + match.Length); i++) { resets[i].Kill(); var timeOffset = Mathf.Lerp(0, 1, i / (float)(text.text.Length - 1)); Tween tween = pair.Key.DoEffect(i, charTweener); currentEffects.Add(tween); tween.fullPosition += timeOffset; } } } for (int i = 0; i < text.text.Length; i++) { // Otherwise we'll linger too long on zero width spaces while (i < text.text.Length && text.text[i] == ZERO_WIDTH_SPACE) { i++; } text.maxVisibleCharacters = (i + 1); yield return(null); } }
private Sequence BounceIn(TMP_Text text, float distance = 50, int?charsAhead = null) { Sequence textSequence = DOTween.Sequence(); CharTweener tweener = text.GetCharTweener(); int count = charsAhead ?? tweener.CharacterCount; for (int i = 0; i < count; i++) { tweener.SetAlpha(i, 0); tweener.SetLocalEulerAngles(i, Vector3.forward * 45); tweener.SetLocalScale(i, 1); tweener.ResetPosition(i); tweener.UpdateCharProperties(); } for (int i = 0; i < count; i++) { Sequence charSequence = DOTween.Sequence(); charSequence.Insert(0, tweener.DOFade(i, 1, 1)); charSequence.Insert(0, tweener.DOOffsetMoveY(i, distance, 0.25f).SetEase(Ease.OutCubic)); charSequence.Insert(0.25f, tweener.DOOffsetMoveY(i, 0, 0.75f).SetEase(Ease.OutBounce)); charSequence.Insert(0.25f, tweener.DOLocalRotate(i, Vector3.zero, 0.75f).SetEase(Ease.OutBounce)); textSequence.Insert((float)i / count, charSequence); } textSequence.SetTarget(text); return(textSequence); }
public void Start() { _tweener = Target.GetCharTweener(); ApplyTweenToLine(0, Tween1); ApplyTweenToLine(1, Tween2); ApplyTweenToLine(2, Tween3); ApplyTweenToLine(3, Tween4); }
async void Start() { text = GetComponent <TMP_Text>(); await new WaitUntil(() => text.text.Length > 0); tweener = text.GetCharTweener(); ApplyTweenToLine(BubblyText); }
private Tween TweenText(string childName, TextTweenOutput output) { TMP_Text textMesh = currentSlide.Find(childName).GetComponent <TMP_Text>(); CharTweener tweener = textMesh.GetCharTweener(); Tween tween = output(textMesh, tweener); tween.SetId(currentSlide); return(tween); }
private void TweenChars(string childName, CharTweenOutput output) { TMP_Text textMesh = currentSlide.Find(childName).GetComponent <TMP_Text>(); CharTweener tweener = textMesh.GetCharTweener(); for (int charIndex = 0; charIndex < tweener.CharacterCount; charIndex++) { Tween tween = output(textMesh, tweener, charIndex); tween.SetId(currentSlide); tween.fullPosition = Mathf.Lerp(0, tween.Duration(includeLoops: false), charIndex / (float)tweener.CharacterCount); } }
private Sequence Drift(TMP_Text text, float strength = 2, int?charsAhead = null) { Sequence textSequence = DOTween.Sequence(); CharTweener tweener = text.GetCharTweener(); int count = charsAhead ?? tweener.CharacterCount; for (int i = 0; i < count; i++) { textSequence.Insert(0, tweener.DODriftPosition(i, Vector3.one * strength, Vector3.one * 0.5f, 5)); } textSequence.SetId(driftTweenId); return(textSequence); }
private Sequence ScaleOut(TMP_Text text, float distance = 100, int?charsAhead = null) { Sequence textSequence = DOTween.Sequence(); CharTweener tweener = text.GetCharTweener(); int count = charsAhead ?? tweener.CharacterCount; for (int i = 0; i < count; i++) { Sequence charSequence = DOTween.Sequence(); charSequence.Insert(0, tweener.DOFade(i, 0, 0.5f).SetEase(Ease.InCubic)); charSequence.Insert(0, tweener.DOScale(i, 0, 0.5f).SetEase(Ease.InBack)); textSequence.Insert((float)i / count * 0.5f, charSequence); } textSequence.SetTarget(text); return(textSequence); }
private void Error(TMP_Text text, int?charsAhead = null) { Sequence textSequence = DOTween.Sequence(); CharTweener tweener = text.GetCharTweener(); DOTween.Kill(tweener, complete: true); int count = charsAhead ?? tweener.CharacterCount; for (int i = 0; i < count; i++) { Sequence charSequence = DOTween.Sequence(); Color oldColor = tweener.GetColor(i); tweener.SetColor(i, Color.red); charSequence.Insert(0, tweener.DOColor(i, oldColor, 0.5f).SetTarget(tweener)); charSequence.Insert(0, tweener.DOShakeRotation(i, 0.5f, Vector3.forward * 25, 20).SetTarget(tweener)); textSequence.Insert((float)i / count * 0.25f, charSequence); } textSequence.SetId(errorId); }
private void Awake() { text = GetComponent <TMP_Text>(); charTween = text.GetCharTweener(); StartCharacterTween(); }