23 lines
548 B
C#
23 lines
548 B
C#
using TMPro;
|
|
using UnityEngine;
|
|
|
|
[RequireComponent(typeof(TextMeshProUGUI))]
|
|
public class BouncyText : MonoBehaviour
|
|
{
|
|
[SerializeField] private float frequency = 2f;
|
|
[SerializeField] private float minSize = 10f;
|
|
[SerializeField] private float maxSize = 12f;
|
|
private TextMeshProUGUI text;
|
|
|
|
void Start()
|
|
{
|
|
text = GetComponent<TextMeshProUGUI>();
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
float newsize = (Mathf.Sin(Time.time * frequency) + 1f) / 2f;
|
|
text.fontSize = Mathf.Lerp(minSize, maxSize, newsize);
|
|
}
|
|
}
|