using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System;
public class NewBehaviourScript : MonoBehaviour
{
public Button btn;
public Text txt;
void Start()
{
btn = GameObject.Find("Button名称").GetComponent<Button>(); //-----------(1)
Text text = btn.transform.Find("Text").GetComponent<Text>(); //------------(2)
//或者吧(1)(2)合并成:
//Text text = GameObject.Find("填写button名/Text").getComponent<Text>();
text.text= "改变的文本值"; //此方法用于改变控件的文本值
}
}
---------------------
作者:金角大王:)
来源:CSDN
原文:https://blog.csdn.net/qq_39628463/article/details/89160320
版权声明:本文为博主原创文章,转载请附上博文链接!