using UnityEngine; using MoreMountains.Tools; #if MM_TEXTMESHPRO using TMPro; #endif namespace MoreMountains.Feedbacks { /// /// A floating text variant using TextMeshPro instead of regular TextMesh /// public class MMFloatingTextMeshPro : MMFloatingText { #if MM_TEXTMESHPRO [Header("TextMeshPro")] /// the TextMeshPro object to use to display values public TextMeshPro TargetTextMeshPro; /// /// On init we grab our TMP's color /// protected override void Initialization() { base.Initialization(); _initialTextColor = TargetTextMeshPro.color; } /// /// Sets the TMP's value /// /// public override void SetText(string newValue) { TargetTextMeshPro.text = newValue; } /// /// Sets the color of the target TMP /// /// public override void SetColor(Color newColor) { TargetTextMeshPro.color = newColor; } /// /// Sets the opacity of the target TMP /// /// public override void SetOpacity(float newOpacity) { _newColor = TargetTextMeshPro.color; _newColor.a = newOpacity; TargetTextMeshPro.color = _newColor; } #endif } }