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 ์ฐ๋๊น ๋๊ธด ํ๋๋ฐ ๋ญ๊ฐ ๋ฌธ์ ์ธ๊ฑฐ์ฃ ?
ํด๋น ๋๊ธ์ ์ญ์ ๋์์ต๋๋ค.
์ ์ ๊ฐ ํ ์คํธ๋ฉ์ํ๋ก ์์ฑํ ๋ 3d ์ค๋ธ์ ํธ๋ก ํ์ด์ผ ํ๋๋ฐ ui๋ก ๋ง๋ค์ด์ ๊ทธ๋ฐ๊ฐ ๋ณด๋ค์