RandomGFGoStop/Assets/Scripts/UI/ScoreCardNumber.cs

43 lines
959 B
C#
Raw Normal View History

2025-08-27 21:08:17 +00:00
using UnityEngine;
public class ScoreCardNumber : MonoBehaviour
{
private TMPro.TextMeshProUGUI tmp;
private RectTransform _rt;
private int _number = 0;
public int Number
{
get => _number;
set
{
_number = value;
tmp.text = _number.ToString();
}
}
public bool Enabled { get => this.gameObject.activeInHierarchy; set => this.gameObject.SetActive(value); }
private void Awake()
{
tmp = this.GetComponentInChildren<TMPro.TextMeshProUGUI>();
_rt = this.GetComponent<RectTransform>();
}
public void Initialize(Transform tran)
{
if (tran != null)
this.transform.SetParent(tran);
Number = 0;
this.Enabled = false;
}
public void SetParent(RectTransform rt)
{
this.transform.SetParent(rt);
this.transform.SetAsLastSibling();
_rt.anchoredPosition = Vector3.zero;
}
}