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) { ParentHouse.GetComponent().Money += add; numText.text = ParentHouse.GetComponent().Money.ToString(); } }