新手求教txt渲染叠加
界面就两个,一个普通文本,一个按钮,写了行代码就是点击按钮后,改变文本内容,但是结果却是,内容渲染叠加。求解,为什么会这样,求解~~~,例如,第一次应该显示“变了哦1”,第二次应该显示“变了哦2”,但是,第二次的内容直接叠加在第一次上面了,而不是替换内容。 图和代码如下:
_mainView = this.GetComponent<UIPanel>().ui;
_mainView.GetChild("n1").text = "";
_mainView.GetChild("btn").onClick.Add(() =>
{
_mainView.GetChild("n1").text = "";
Debug.Log("点击了一下!");
count++;
_mainView.GetChild("n1").text = "变了哦"+count;
});
_mainView = this.GetComponent<UIPanel>().ui;
_mainView.GetChild("n1").text = "";
_mainView.GetChild("btn").onClick.Add(() =>
{
_mainView.GetChild("n1").text = "";
Debug.Log("点击了一下!");
count++;
_mainView.GetChild("n1").text = "变了哦"+count;
});
没有找到相关结果
已邀请:
1 个回复
谷主
赞同来自: