using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class TextBox : MonoBehaviour { public Text numText; public Transform ParentHouse; public Transform Parent; // Start is called before the first frame update void Start() { transform.SetParent(Parent);//改变父节点,显示出来 numText = transform.Find("Text").GetComponent(); SetText(0); } public void SetText(float add) { float start = ParentHouse.GetComponent().Money; ParentHouse.GetComponent().Money = add; StartCoroutine(Tools.AnimateText(start, ParentHouse.GetComponent().Money, 0.5f, numText)); } public void AddText(float add) { float start = ParentHouse.GetComponent().Money; ParentHouse.GetComponent().Money += add; StartCoroutine(Tools.AnimateText(start, ParentHouse.GetComponent().Money,0.5f,numText)); } public float ReturnText() { return ParentHouse.GetComponent().Money; } public void PlayAni() { ParentHouse.GetComponent().PlayCoinAnimation(); } }