当前位置:   article > 正文

Unity 点击对话系统(含Demo)_unity中点击就出现下一段对话

unity中点击就出现下一段对话

点击对话系统

可实现点击物体后自动移动到物体附近,然后弹出对话框进行对话。
在这里插入图片描述
在这里插入图片描述

基于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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Li_阴宅/article/detail/783202
推荐阅读
相关标签
  

闽ICP备14008679号