using System.Collections; using System.Collections.Generic; using UnityEngine; using TMPro; public class DamageText : MonoBehaviour { private float moveSpeed; private float alphaSpeed; private float destroyTime; TextMeshPro text; Color alpha; public int damage; // Start is called before the first frame update void Start() { moveSpeed = 2.0f; alphaSpeed = 2.0f; destroyTime = 2.0f; text = GetComponent<TextMeshPro>(); alpha = text.color; text.text = damage.ToString(); Invoke("DestroyObject", destroyTime); } // Update is called once per frame void Update() { transform.Translate(new Vector3(0, moveSpeed * Time.deltaTime, 0)); // ํ…์ŠคํŠธ ์œ„์น˜ alpha.a = Mathf.Lerp(alpha.a, 0, Time.deltaTime * alphaSpeed); // ํ…์ŠคํŠธ ์•ŒํŒŒ๊ฐ’ text.color = alpha; } private void DestroyObject() { Destroy(gameObject); } }


ํ”Œ๋กœํŒ… ํ…์ŠคํŠธ ์ณ์„œ ๋‚˜์˜ค๋Š” ๋ธ”๋กœ๊ทธ์— ์žˆ๋Š”๊ฑฐ ๋”ฐ๋ผ์น˜๊ณ  ์žˆ๋Š”๋ฐ ์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ์•ŒํŒŒ๊ฐ’์ด๋ž‘ ๋ฐ๋ฏธ์ง€ ๋ฐ›๋Š” ๋ถ€๋ถ„์—์„œ ์˜ค๋ฅ˜๋œจ๋”๋ผ๊ตฌ์š”

TextMeshProUGUI ์“ฐ๋‹ˆ๊นŒ ๋˜๊ธด ํ•˜๋˜๋ฐ ๋ญ๊ฐ€ ๋ฌธ์ œ์ธ๊ฑฐ์ฃ ?