游戏中有对话情节,需求是:游戏暂停 界面所有UI隐藏 npc与玩家对话
这里复制上项目的涉及到此功能的一小段代码。
private List<string> content;//对话内容
private int tempid = 0; //第几句话
public Text txt_Task; //文本
private void PlayTaskContent(List<string> _content) {
//界面隐藏
//停止活动
Time.timeScale = 0;
//播放对话
txt_Task.text = "";
tempid = -1;
content = _content;
PlayNextText();
}
private int timeCount =0;
private void PlayNextText() {
Debug.Log("播放一句话");
tempid++;
if (tempid< content.Count) {
txt_Task.text = "";
float _time = content[tempid].Length / 10;
Tweener tweener = txt_Task.DOText(content[tempid], _time);
tweener.SetUpdate(true);
Tween t = DOTween.To(() => timeCount, a => timeCount = a, 1, 2).OnStepComp