赞
踩
可实现点击物体后自动移动到物体附近,然后弹出对话框进行对话。
基于Unity 简单角色对话UI脚本的编写(新版UI组件)和Unity 关于点击不同物品移动并触发不同事件的结合体,有兴趣可以看一下之前文章。
下边代码为UI界面的公共脚本:
public class DialogueUI : MonoBehaviour { private TextMeshProUGUI nameTexe;//获取名称的Text组件 private TextMeshProUGUI descriptionTexe; //获取内容的Text组件 private Button resumeButton;//继续对话的按钮 public List<string> contentlist;//对话列表 private int contentIndex = 0;//对话数组 private void Start() { //获取组件 nameTexe = transform.Find("NameText").GetComponent<TextMeshProUGUI>(); descriptionTexe= transform.Find("ContentText").GetComponent<TextMeshProUGUI>(); resumeButton = transform.Find("ResumeButton").GetComponent<Button>(); resumeButton.onClick.AddListener(this.OnContinueButtonC
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。