123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239 |
- using UnityEngine;
- using TMPro;
- namespace DG.Tweening
- {
-
-
-
- public static class ShortcutExtensionsTextMeshPro
- {
- #region Colors
-
-
-
- public static Tweener DOColor(this TextMeshPro target, Color endValue, float duration)
- {
- return DOTween.To(() => target.color, x => target.color = x, endValue, duration)
- .SetTarget(target);
- }
-
-
-
- public static Tweener DOFaceColor(this TextMeshPro target, Color32 endValue, float duration)
- {
- return DOTween.To(() => target.faceColor, x => target.faceColor = x, endValue, duration)
- .SetTarget(target);
- }
-
-
-
- public static Tweener DOOutlineColor(this TextMeshPro target, Color32 endValue, float duration)
- {
- return DOTween.To(() => target.outlineColor, x => target.outlineColor = x, endValue, duration)
- .SetTarget(target);
- }
-
-
-
-
- public static Tweener DOGlowColor(this TextMeshPro target, Color endValue, float duration, bool useSharedMaterial = false)
- {
- return useSharedMaterial
- ? target.fontSharedMaterial.DOColor(endValue, "_GlowColor", duration).SetTarget(target)
- : target.fontMaterial.DOColor(endValue, "_GlowColor", duration).SetTarget(target);
- }
-
-
-
- public static Tweener DOFade(this TextMeshPro target, float endValue, float duration)
- {
- return DOTween.ToAlpha(() => target.color, x => target.color = x, endValue, duration)
- .SetTarget(target);
- }
-
-
-
- public static Tweener DOFaceFade(this TextMeshPro target, float endValue, float duration)
- {
- return DOTween.ToAlpha(() => target.faceColor, x => target.faceColor = x, endValue, duration)
- .SetTarget(target);
- }
- #endregion
- #region Other
-
-
-
- public static Tweener DOScale(this TextMeshPro target, float endValue, float duration)
- {
- Transform t = target.transform;
- Vector3 endValueV3 = new Vector3(endValue, endValue, endValue);
- return DOTween.To(() => t.localScale, x => t.localScale = x, endValueV3, duration).SetTarget(target);
- }
-
-
-
- public static Tweener DOFontSize(this TextMeshPro target, float endValue, float duration)
- {
- return DOTween.To(() => target.fontSize, x => target.fontSize = x, endValue, duration)
- .SetTarget(target);
- }
-
-
-
- public static Tweener DOMaxVisibleCharacters(this TextMeshPro target, int endValue, float duration)
- {
- return DOTween.To(() => target.maxVisibleCharacters, x => target.maxVisibleCharacters = x, endValue, duration)
- .SetTarget(target);
- }
-
-
-
-
-
-
-
-
-
- public static Tweener DOText(this TextMeshPro target, string endValue, float duration, bool richTextEnabled = true, ScrambleMode scrambleMode = ScrambleMode.None, string scrambleChars = null)
- {
- return DOTween.To(() => target.text, x => target.text = x, endValue, duration)
- .SetOptions(richTextEnabled, scrambleMode, scrambleChars)
- .SetTarget(target);
- }
- #endregion
- }
-
-
-
- public static class ShortcutExtensionsTextMeshProUGUI
- {
- #region Colors
-
-
-
- public static Tweener DOColor(this TextMeshProUGUI target, Color endValue, float duration)
- {
- return DOTween.To(() => target.color, x => target.color = x, endValue, duration)
- .SetTarget(target);
- }
-
-
-
- public static Tweener DOFaceColor(this TextMeshProUGUI target, Color32 endValue, float duration)
- {
- return DOTween.To(() => target.faceColor, x => target.faceColor = x, endValue, duration)
- .SetTarget(target);
- }
-
-
-
- public static Tweener DOOutlineColor(this TextMeshProUGUI target, Color32 endValue, float duration)
- {
- return DOTween.To(() => target.outlineColor, x => target.outlineColor = x, endValue, duration)
- .SetTarget(target);
- }
-
-
-
-
- public static Tweener DOGlowColor(this TextMeshProUGUI target, Color endValue, float duration, bool useSharedMaterial = false)
- {
- return useSharedMaterial
- ? target.fontSharedMaterial.DOColor(endValue, "_GlowColor", duration).SetTarget(target)
- : target.fontMaterial.DOColor(endValue, "_GlowColor", duration).SetTarget(target);
- }
-
-
-
- public static Tweener DOFade(this TextMeshProUGUI target, float endValue, float duration)
- {
- return DOTween.ToAlpha(() => target.color, x => target.color = x, endValue, duration)
- .SetTarget(target);
- }
-
-
-
- public static Tweener DOFaceFade(this TextMeshProUGUI target, float endValue, float duration)
- {
- return DOTween.ToAlpha(() => target.faceColor, x => target.faceColor = x, endValue, duration)
- .SetTarget(target);
- }
- #endregion
- #region Other
-
-
-
- public static Tweener DOScale(this TextMeshProUGUI target, float endValue, float duration)
- {
- Transform t = target.transform;
- Vector3 endValueV3 = new Vector3(endValue, endValue, endValue);
- return DOTween.To(() => t.localScale, x => t.localScale = x, endValueV3, duration).SetTarget(target);
- }
-
-
-
- public static Tweener DOFontSize(this TextMeshProUGUI target, float endValue, float duration)
- {
- return DOTween.To(() => target.fontSize, x => target.fontSize = x, endValue, duration)
- .SetTarget(target);
- }
-
-
-
- public static Tweener DOMaxVisibleCharacters(this TextMeshProUGUI target, int endValue, float duration)
- {
- return DOTween.To(() => target.maxVisibleCharacters, x => target.maxVisibleCharacters = x, endValue, duration)
- .SetTarget(target);
- }
-
-
-
-
-
-
-
-
-
- public static Tweener DOText(this TextMeshProUGUI target, string endValue, float duration, bool richTextEnabled = true, ScrambleMode scrambleMode = ScrambleMode.None, string scrambleChars = null)
- {
- return DOTween.To(() => target.text, x => target.text = x, endValue, duration)
- .SetOptions(richTextEnabled, scrambleMode, scrambleChars)
- .SetTarget(target);
- }
- #endregion
- }
- }
|