{"id":782,"date":"2020-06-17T21:08:51","date_gmt":"2020-06-17T13:08:51","guid":{"rendered":"http:\/\/summid.icu\/?p=782"},"modified":"2023-06-01T15:18:49","modified_gmt":"2023-06-01T07:18:49","slug":"unity2ddialoguesystem","status":"publish","type":"post","link":"https:\/\/summid.icu\/index.php\/2020\/06\/17\/unity2ddialoguesystem\/","title":{"rendered":"Unity2D\u5bf9\u8bdd\u7cfb\u7edf"},"content":{"rendered":"<p><!--more--><\/p>\n<h1><span style=\"font-family: 'Microsoft YaHei', 'Microsoft JhengHei', \u9ed1\u4f53; font-size: 24pt; color: #000000;\">\u6982\u8ff0<\/span><\/h1>\n\n\n<figure class=\"wp-block-image size-large\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/summid.icu\/wp-content\/uploads\/2020\/06\/Dialog_Demo_Gif.gif'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"720\" height=\"456\" data-original=\"https:\/\/summid.icu\/wp-content\/uploads\/2020\/06\/Dialog_Demo_Gif.gif\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-783\"\/><\/div><\/figure>\n\n\n<p style=\"margin: 0in; font-family: 'Microsoft YaHei'; font-size: 14.0pt;\"><span lang=\"zh-CN\">\u5f53\u73a9\u5bb6\u89d2\u8272\u79fb\u52a8\u5230<\/span><span lang=\"en-US\">NPC<\/span><span lang=\"zh-CN\">\u8eab\u8fb9\u65f6\uff0c<\/span><span lang=\"en-US\">NPC<\/span><span lang=\"zh-CN\">\u5934\u4e0a\u4f1a\u663e\u793a<\/span><span lang=\"en-US\">\u201cR<\/span><span lang=\"zh-CN\">\u952e<\/span><span lang=\"en-US\">\u201d<\/span><span lang=\"zh-CN\">\u56fe\u6807\u3002<\/span><\/p>\n<p style=\"margin: 0in; font-family: 'Microsoft YaHei'; font-size: 14.0pt;\"><span lang=\"zh-CN\">\u6b64\u65f6\u6309\u4e0b<\/span><span lang=\"en-US\">R<\/span><span lang=\"zh-CN\">\u952e\u4f1a\u5f39\u51fa\u5bf9\u8bdd\u6846\uff0c\u663e\u793a\u89d2\u8272\u53f0\u8bcd\uff0c\u5e76\u5728\u5bf9\u8bdd\u6846\u5de6\u4fa7\u663e\u793a\u5f53\u524d\u8bf4\u8bdd\u89d2\u8272\u7684\u5934\u50cf\uff0c\u518d\u6b21\u6309\u4e0b<\/span><span lang=\"en-US\">R<\/span><span lang=\"zh-CN\">\u952e\u663e\u793a\u4e0b\u4e00\u53e5\u53f0\u8bcd\uff1b\u5f53\u5bf9\u8bdd\u7ed3\u675f\uff0c\u6309\u4e0b<\/span><span lang=\"en-US\">R<\/span><span lang=\"zh-CN\">\u952e\u5219\u5173\u95ed\u5bf9\u8bdd\u6846\u3002<\/span><\/p>\n<p><span style=\"font-family: 'Microsoft YaHei', 'Microsoft JhengHei', \u9ed1\u4f53; font-size: 14pt;\">\u9879\u76ee\u7ec6\u8282\u5305\u62ec\uff1a<\/span><\/p>\n<ul>\n<li>\n<p style=\"margin: 0in; font-family: 'Microsoft YaHei'; font-size: 14.0pt;\"><span lang=\"zh-CN\">\u5c06<\/span><span lang=\"en-US\">TextAsset<\/span><span lang=\"zh-CN\">\u6587\u4ef6\u4e2d\u7684\u6587\u672c\u663e\u793a\u5728\u5bf9\u8bdd\u6846\u4e2d\u3002<\/span><\/p>\n<\/li>\n<li>\n<p style=\"margin: 0in; font-family: 'Microsoft YaHei'; font-size: 14.0pt;\">\u4f7f\u7528\u534f\u7a0b\u8ba9\u53f0\u8bcd\u6309\u987a\u5e8f\u9010\u4e2a\u5b57\u7b26\u663e\u793a\u3002<\/p>\n<\/li>\n<li>\n<p style=\"margin: 0in; font-family: 'Microsoft YaHei'; font-size: 14.0pt;\"><span lang=\"zh-CN\">\u5f53\u53f0\u8bcd\u8fd8\u5728\u5c55\u5f00\u8fc7\u7a0b\u4e2d\uff0c\u63d0\u524d\u6309\u4e0b<\/span><span lang=\"en-US\">R<\/span><span lang=\"zh-CN\">\u952e\uff0c\u76f4\u63a5\u663e\u793a\u5b8c\u6574\u53f0\u8bcd\u3002<\/span><\/p>\n<\/li>\n<\/ul>\n<p><span style=\"font-family: 'Microsoft YaHei', 'Microsoft JhengHei', \u9ed1\u4f53; font-size: 14pt;\">\u611f\u8c22\u9ea6\u6263\u8001\u5e08\uff1a<a href=\"https:\/\/m-studio-m.github.io\/\">https:\/\/m-studio-m.github.io\/<\/a><\/span><\/p>\n\n\n<hr class=\"wp-block-separator is-style-wide\"\/>\n\n\n<h1><span style=\"font-family: 'Microsoft YaHei', 'Microsoft JhengHei', \u9ed1\u4f53; font-size: 24pt; color: #000000;\">UI\u5236\u4f5c<\/span><\/h1>\n\n\n<figure class=\"wp-block-image size-large\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/summid.icu\/wp-content\/uploads\/2020\/06\/Dialog_0.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"136\" height=\"67\" data-original=\"https:\/\/summid.icu\/wp-content\/uploads\/2020\/06\/Dialog_0.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-787\"\/><\/div><\/figure>\n\n\n<p style=\"margin: 0in; font-family: 'Microsoft YaHei'; font-size: 14.0pt;\"><span lang=\"zh-CN\">\u9879\u76ee\u4e2d\u4f7f\u7528<\/span><span lang=\"en-US\">Panel<\/span><span lang=\"zh-CN\">\u6765\u5145\u5f53\u6587\u672c\u6846\uff0c\u5728\u5176\u4e0b\u65b9\u518d\u521b\u5efa<\/span><span lang=\"en-US\">Text<\/span><span lang=\"zh-CN\">\u548c<\/span><span lang=\"en-US\">Image<\/span><span lang=\"zh-CN\">\u6e38\u620f\u7269\u4f53\u6765\u627f\u62c5\u6587\u672c\u548c\u56fe\u50cf\u663e\u793a\u5de5\u4f5c\u3002<\/span><\/p>\n\n\n<figure class=\"wp-block-image size-large\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/summid.icu\/wp-content\/uploads\/2020\/06\/Dialog_1.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"319\" height=\"131\" data-original=\"https:\/\/summid.icu\/wp-content\/uploads\/2020\/06\/Dialog_1.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-788\"  sizes=\"auto, (max-width: 319px) 100vw, 319px\" \/><\/div><\/figure>\n\n\n<p style=\"margin: 0in; font-family: 'Microsoft YaHei'; font-size: 14.0pt;\"><span lang=\"zh-CN\">\u7279\u522b\u7684\uff0c\u9879\u76ee\u7684<\/span><span lang=\"en-US\">Canvas<\/span><span lang=\"zh-CN\">\u7684<\/span><span lang=\"en-US\">RenderMode<\/span><span lang=\"zh-CN\">\u8bbe\u7f6e\u4e3a<\/span><span lang=\"en-US\">World Space<\/span><span lang=\"zh-CN\">\uff0c\u8fd9\u6837<\/span><span lang=\"en-US\">Panel<\/span><span lang=\"zh-CN\">\u5c31\u4e0d\u4f1a\u906e\u76d6\u4f4f\u6574\u4e2a\u5c4f\u5e55\u3002<\/span><\/p>\n<p style=\"margin: 0in; font-family: 'Microsoft YaHei'; font-size: 14.0pt;\"><span lang=\"zh-CN\">\u56e0\u6b64\uff0c<\/span><span lang=\"en-US\">Event Camera<\/span><span lang=\"zh-CN\">\u8bbe\u7f6e\u4e3a\u4e3b\u6444\u50cf\u673a\u3002<\/span><\/p>\n<p style=\"margin: 0in; font-family: 'Microsoft YaHei'; font-size: 14.0pt;\"><span lang=\"zh-CN\">\u4e3a\u4e86\u8ba9\u5bf9\u8bdd\u6846\u663e\u793a\u5728\u6700\u4e0a\u5c42\uff0c<\/span><span lang=\"en-US\">Order in Layer<\/span><span lang=\"zh-CN\">\u7684\u503c\u4e3a<\/span><span lang=\"en-US\">10<\/span><span lang=\"zh-CN\">\u3002<\/span><\/p>\n<p style=\"margin: 0in; font-family: 'Microsoft YaHei'; font-size: 14.0pt;\">\n<\/p><p style=\"margin: 0in; font-family: 'Microsoft YaHei'; font-size: 14.0pt;\"><span lang=\"zh-CN\">\u4e4b\u540e\u8c03\u6574\u597d<\/span><span lang=\"en-US\">UI<\/span><span lang=\"zh-CN\">\u4f4d\u7f6e\u5373\u53ef\u3002<\/span><\/p>\n\n\n<hr class=\"wp-block-separator is-style-wide\"\/>\n\n\n<h1><span style=\"font-family: 'Microsoft YaHei', 'Microsoft JhengHei', \u9ed1\u4f53; font-size: 24pt; color: #000000;\">\u5c06TextAsset\u4e2d\u7684\u6587\u672c\u663e\u793a\u5728\u5bf9\u8bdd\u6846\u4e2d<\/span><\/h1>\n<p><span style=\"font-family: 'Microsoft YaHei', 'Microsoft JhengHei', \u9ed1\u4f53; font-size: 14pt;\">\u8fd9\u4e00\u8282\u5c06\u7528\u5230TextAsset\u7c7b\u578b\u53d8\u91cf\u3002<\/span><\/p>\n\n\n<figure class=\"wp-block-image size-large\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/summid.icu\/wp-content\/uploads\/2020\/06\/Dialog_2.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"499\" height=\"379\" data-original=\"https:\/\/summid.icu\/wp-content\/uploads\/2020\/06\/Dialog_2.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-790\"  sizes=\"auto, (max-width: 499px) 100vw, 499px\" \/><\/div><\/figure>\n\n\n<p style=\"margin: 0in; font-family: 'Microsoft YaHei'; font-size: 14.0pt;\"><span lang=\"zh-CN\">\u5f53\u6211\u4eec\u628a\u4e00\u4e2a\u6587\u672c\u6587\u4ef6\u653e\u5230\u9879\u76ee\u6587\u4ef6\u5939\u4e2d\u540e\uff0c\u5b83\u5c06\u88ab\u8f6c\u6362\u4e3a<\/span><span lang=\"en-US\">TextAsset<\/span><span lang=\"zh-CN\">\u3002\u901a\u8fc7\u8bfb\u53d6<\/span><span lang=\"en-US\">TextAsset<\/span><span lang=\"zh-CN\">\u6587\u4ef6\uff0c\u5c31\u80fd\u8bbf\u95ee\u5230\u6211\u4eec\u5728\u6587\u672c\u6587\u4ef6\u4e2d\u4fdd\u5b58\u7684\u4fe1\u606f\u3002<\/span><\/p>\n<p style=\"margin: 0in; font-family: 'Microsoft YaHei'; font-size: 14.0pt;\">\u8fd9\u91cc\u7684\u201c\u6587\u672c\u6587\u4ef6\u201d\u652f\u6301\u4e0a\u9762\u5217\u51fa\u7684\u683c\u5f0f\uff0c\u8fd9\u91cc\u4e3a\u4e86\u65b9\u4fbf\u6211\u4eec\u5c31\u7528txt\u683c\u5f0f\u3002<\/p>\n\n\n<figure class=\"wp-block-image size-large\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/summid.icu\/wp-content\/uploads\/2020\/06\/Dialog_3.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"513\" height=\"219\" data-original=\"https:\/\/summid.icu\/wp-content\/uploads\/2020\/06\/Dialog_3.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-791\"  sizes=\"auto, (max-width: 513px) 100vw, 513px\" \/><\/div><\/figure>\n\n\n<p style=\"margin: 0in; font-family: 'Microsoft YaHei'; font-size: 14.0pt;\"><span lang=\"zh-CN\">\u6211\u4eec\u521b\u5efa\u811a\u672c<\/span><span lang=\"en-US\">DialogSystem<\/span><span lang=\"zh-CN\">\uff0c\u5e76\u5c06\u5b83\u6302\u8f7d\u5728<\/span><span lang=\"en-US\">Panel<\/span><span lang=\"zh-CN\">\u4e0a\u3002\uff08\u53ef\u4ee5\u6839\u636e\u9700\u8981\uff0c\u5c06\u5b83\u6302\u8f7d\u5176\u4ed6\u7269\u4f53\u4e0a\uff09<\/span><\/p>\n\n\n<figure class=\"wp-block-image size-large\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/summid.icu\/wp-content\/uploads\/2020\/06\/Dialog_4.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"335\" height=\"600\" data-original=\"https:\/\/summid.icu\/wp-content\/uploads\/2020\/06\/Dialog_4.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-792\"  sizes=\"auto, (max-width: 335px) 100vw, 335px\" \/><\/div><\/figure>\n\n\n<p style=\"margin: 0in; font-family: 'Microsoft YaHei'; font-size: 14.0pt;\">\u6210\u5458\u53d8\u91cf\uff1a<\/p>\n<ul>\n<li>\n<p style=\"margin: 0in; font-family: 'Microsoft YaHei'; font-size: 14.0pt;\"><span lang=\"zh-CN\">text<\/span><span lang=\"en-US\">Label<\/span><span lang=\"zh-CN\">\uff1a\u6587\u672c\u6846<\/span><span lang=\"en-US\">Panel<\/span><span lang=\"zh-CN\">\u4e0b\u7684<\/span><span lang=\"en-US\">Text<\/span><span lang=\"zh-CN\">\u7269\u4f53\u3002<\/span><\/p>\n<\/li>\n<li style=\"margin-top: 0; margin-bottom: 0; vertical-align: middle;\"><span lang=\"zh-CN\" style=\"font-family: 'Microsoft YaHei'; font-size: 14.0pt;\">text<\/span><span lang=\"en-US\" style=\"font-family: 'Microsoft YaHei'; font-size: 14.0pt;\">File<\/span><span lang=\"zh-CN\" style=\"font-family: 'Microsoft YaHei'; font-size: 14.0pt;\">\uff1a\u6211\u4eec\u51c6\u5907\u7684txt\u6587\u672c\u6587\u4ef6\u3002<\/span><\/li>\n<li>\n<p style=\"margin: 0in; font-family: 'Microsoft YaHei'; font-size: 14.0pt;\">index\uff1a\u5f53\u524d\u663e\u793a\u7684\u6587\u672c\u884c\u6570\u7d22\u5f15\u503c\u3002<\/p>\n<\/li>\n<li>\n<p style=\"margin: 0in; font-family: 'Microsoft YaHei'; font-size: 14.0pt;\"><span lang=\"zh-CN\">text<\/span><span lang=\"en-US\">List<\/span><span lang=\"zh-CN\">\uff1a\u5b58\u653e\u5b57\u7b26\u4e32\u7684\u5217\u8868\u3002<\/span><\/p>\n<\/li>\n<\/ul>\n<p style=\"margin: 0in; font-family: 'Microsoft YaHei'; font-size: 14.0pt;\">\u6210\u5458\u65b9\u6cd5\uff1a<\/p>\n<ul>\n<li>\n<p style=\"margin: 0in; font-family: 'Microsoft YaHei'; font-size: 14.0pt;\"><span lang=\"en-US\">GetTextFromFile(TextAsset file)<\/span><span lang=\"zh-CN\">\uff1a\u5728\u8be5\u65b9\u6cd5\u4e2d\uff0c\u6211\u4eec\u8981\u5c06<\/span><span lang=\"en-US\">textFile<\/span><span lang=\"zh-CN\">\u6587\u4ef6\u4e2d\u7684\u6587\u672c\u6309\u7167\u6362\u884c\u7b26\u5206\u5272\u6210\u53e5\u5b50\uff0c\u5e76\u5c06\u53e5\u5b50\u6309\u6bcf\u4e00\u53e5\u5b58\u653e\u8fdbtextList\u5217\u8868\u3002<\/span><\/p>\n<\/li>\n<li>\n<p style=\"margin: 0in; font-family: 'Microsoft YaHei'; font-size: 14.0pt;\"><span lang=\"en-US\">Awake()<\/span><span lang=\"zh-CN\">\uff1a\u5728\u8be5\u65b9\u6cd5\u4e2d\u8c03\u7528<\/span><span lang=\"en-US\">GetTextFromFile(TextAsset file)<\/span><span lang=\"zh-CN\">\u65b9\u6cd5\u8fdb\u884c\u53e5\u5b50\u5206\u5272\u3002<\/span><\/p>\n<\/li>\n<li>\n<p style=\"margin: 0in; font-family: 'Microsoft YaHei'; font-size: 14.0pt;\"><span lang=\"en-US\">Update()<\/span><span lang=\"zh-CN\">\uff1a\u5224\u65ad\u73a9\u5bb6\u662f\u5426\u6309\u4e0b<\/span><span lang=\"en-US\">R<\/span><span lang=\"zh-CN\">\u952e\uff0c\u82e5\u6309\u4e0b<\/span><span lang=\"en-US\">R<\/span><span lang=\"zh-CN\">\u952e\uff0c\u5219\u5c06<\/span><span lang=\"en-US\">textList<\/span><span lang=\"zh-CN\">\u4e2d\u5b58\u653e\u7684\u5143\u7d20\u8d4b\u503c\u7ed9textLabel\uff0c\u5b9e\u73b0\u663e\u793a\u53f0\u8bcd\u7684\u529f\u80fd\u3002\u7279\u522b\u7684\uff0c\u5f53index\u6307\u5411text<\/span><span lang=\"en-US\">Label<\/span><span lang=\"zh-CN\">\u6700\u540e\u4e00\u9879\u5143\u7d20\u65f6\uff0c\u6309\u4e0b<\/span><span lang=\"en-US\">R<\/span><span lang=\"zh-CN\">\u952e\u5219\u5173\u95ed\u5bf9\u8bdd\u6846\u3002<\/span><\/p>\n<\/li>\n<li>\n<p style=\"margin: 0in; font-family: 'Microsoft YaHei'; font-size: 14.0pt;\"><span lang=\"en-US\">OnEnable()<\/span><span lang=\"zh-CN\">\uff1a\u5f53\u5bf9\u8bdd\u6846\u88ab\u8c03\u51fa\u540e\uff0c\u81ea\u52a8\u663e\u793a\u7b2c\u4e00\u53e5\u8bdd\u3002<\/span><\/p>\n<\/li>\n<\/ul>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">using System.Collections;\nusing System.Collections.Generic;\nusing UnityEngine;\nusing UnityEngine.UI;\n\npublic class DialogSystem : MonoBehaviour\n{\n    [Header(\"UI\u7ec4\u4ef6\")]\n    public Text textLabel;\n\n    [Header(\"\u6587\u672c\u6587\u4ef6\")]\n    public TextAsset textFile;\n    public int index;\n\n    private List&lt;string> textList = new List&lt;string>();\n\n    private void Awake()\n    {\n        \/\/\u6587\u672c\u6846\u5c31\u7eea\u524d\u5c06\u6587\u672c\u6587\u4ef6\u4e2d\u7684\u5185\u5bb9\u653e\u8fdbtextList\u4e2d\n        GetTextFromFile(textFile);\n    }\n\n    \/\/\u5f53\u6587\u672c\u6846\u5c31\u7eea\u540e\uff0c\u5c31\u663e\u793a\u7b2c\u4e00\u6761\u6587\u672c\n    private void OnEnable()\/\/\u4f1a\u6bd4Start\u5148\u8c03\u7528\n    {\n        textLabel.text = textList[index];\n        index++;\n    }\n\n    private void Update()\n    {\n        \/\/\u5f53\u6309\u4e0bR\u952e\uff0c\u4e14\u6700\u540e\u4e00\u6761\u6587\u672c\u5df2\u7ecf\u5c55\u793a\u5b8c\uff0c\u5219\u5173\u95ed\u5bf9\u8bdd\u6846\uff0c\u91cd\u7f6eindex\n        if (Input.GetKeyDown(KeyCode.R) &amp;&amp; index == textList.Count)\n        {\n            gameObject.SetActive(false);\n            index = 0;\n            return;\n        }\n        \/\/\u5f53\u6309\u4e0bR\u952e\uff0c\u663e\u793a\u4e0b\u4e00\u6761\u6587\u672c\n        if (Input.GetKeyDown(KeyCode.R) &amp;&amp; textFinished)\n        {\n            textLabel.text = textList[index];\n            index++;\n        }\n    }\n\n    \/\/\u5c06TextAsset\u6587\u4ef6\u6309\u7167\u6bcf\u4e00\u884c\u5207\u5272\u6210\u5b57\u7b26\u4e32\uff0c\u6dfb\u52a0\u8fdbtextList\u91cc\n    private void GetTextFromFile(TextAsset file)\n    {\n        textList.Clear();\n        index = 0;\n\n        \/\/\u5c06TextAsset\u6587\u4ef6\u6309\u7167\u6362\u884c\u5207\u5272\u6210\u5b57\u7b26\u4e32\n        \/\/windows\u6362\u884c\u7b26\u662f\\r\\n\uff0c\u518d\u53bb\u6389\u7a7a\u5143\u7d20\n        string[] lineDate = file.text.Split(new char[] { '\\r', '\\n' }, System.StringSplitOptions.RemoveEmptyEntries);\n\n\n        foreach (string line in lineDate)\n        {\n            textList.Add(line);\n        }\n    }<\/pre>\n\n\n\n<hr class=\"wp-block-separator is-style-wide\"\/>\n\n\n<h1><span style=\"font-family: 'Microsoft YaHei', 'Microsoft JhengHei', \u9ed1\u4f53; font-size: 24pt; color: #000000;\">\u5b9e\u73b0\u8ba9\u53f0\u8bcd\u6309\u987a\u5e8f\u9010\u4e2a\u5b57\u7b26\u663e\u793a<\/span><\/h1>\n<p style=\"margin: 0in; font-family: 'Microsoft YaHei'; font-size: 14.0pt;\">\u8fd9\u4e00\u8282\u5c06\u4ecb\u7ecd\u5982\u4f55\u7528\u534f\u7a0b\u6765\u5b9e\u73b0\u6309\u987a\u5e8f\u9010\u4e2a\u5b57\u7b26\u663e\u793a\u53f0\u8bcd\u3002<\/p>\n<p style=\"margin: 0in; font-family: 'Microsoft YaHei'; font-size: 14.0pt;\">\n<\/p><p style=\"margin: 0in; font-family: 'Microsoft YaHei'; font-size: 14.0pt;\">\u6211\u4eec\u4fee\u6539\u811a\u672c\uff0c\u5e76\u5c06\u663e\u793a\u8bf4\u8bdd\u4eba\u7269\u7684\u5934\u50cf\u529f\u80fd\u4e5f\u987a\u4fbf\u505a\u4e86\u3002<\/p>\n\n\n<figure class=\"wp-block-image size-large\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/summid.icu\/wp-content\/uploads\/2020\/06\/Dialog_5.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"333\" height=\"811\" data-original=\"https:\/\/summid.icu\/wp-content\/uploads\/2020\/06\/Dialog_5.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-796\"  sizes=\"auto, (max-width: 333px) 100vw, 333px\" \/><\/div><\/figure>\n\n\n<p style=\"margin: 0in; font-family: 'Microsoft YaHei'; font-size: 14.0pt;\">\u6210\u5458\u53d8\u91cf\uff1a<\/p>\n<ul>\n<li>\n<p style=\"margin: 0in; font-family: 'Microsoft YaHei'; font-size: 14.0pt;\"><span lang=\"zh-CN\">face<\/span><span lang=\"en-US\">Image<\/span><span lang=\"zh-CN\">\uff1a\u6587\u672c\u6846<\/span><span lang=\"en-US\">Panel<\/span><span lang=\"zh-CN\">\u4e0b\u7684<\/span><span lang=\"en-US\">Image<\/span><span lang=\"zh-CN\">\u7269\u4f53\u3002<\/span><\/p>\n<\/li>\n<li>\n<p style=\"margin: 0in; font-family: 'Microsoft YaHei'; font-size: 14.0pt;\">textSpeed\uff1a\u6587\u672c\u6846\u663e\u793a\u901f\u5ea6\uff0c\u6bcf\u4e2a\u5b57\u7b26\u663e\u793a\u4e2d\u95f4\u7684\u95f4\u9694\u65f6\u95f4\u3002<\/p>\n<\/li>\n<li>\n<p style=\"margin: 0in; font-family: 'Microsoft YaHei'; font-size: 14.0pt;\"><span lang=\"zh-CN\">text<\/span><span lang=\"en-US\">Finished<\/span><span lang=\"zh-CN\">\uff1a\u5224\u65ad\u5f53\u524d\u8fd9\u4e00\u53e5\u53f0\u8bcd\u662f\u5426\u663e\u793a\u5b8c\u6bd5\uff0c\u82e5\u6ca1\u6709\uff0c\u5219\u73a9\u5bb6\u6309\u4e0b<\/span><span lang=\"en-US\">R<\/span><span lang=\"zh-CN\">\u952e\u4e0d\u53d7\u7406\uff0c\u4e0d\u7136\u4f1a\u51fa\u73b0\u4e71\u7801\u3002<\/span><\/p>\n<\/li>\n<\/ul>\n<p style=\"margin: 0in; font-family: 'Microsoft YaHei'; font-size: 14.0pt;\">\u6210\u5458\u65b9\u6cd5\uff1a<\/p>\n<ul>\n<li>\n<p style=\"margin: 0in; font-family: 'Microsoft YaHei'; font-size: 14.0pt;\"><span lang=\"en-US\">IEnumerator SetTextUI()<\/span><span lang=\"zh-CN\">\uff1a<\/span><span lang=\"en-US\">Update()<\/span><span lang=\"zh-CN\">\u65b9\u6cd5\u4e2d\uff0c\u4f1a\u4f7f\u7528<\/span><span lang=\"en-US\">StartCoroutine(SetTextUI())<\/span><span lang=\"zh-CN\">\u5f00\u542f\u534f\u7a0b\uff0c\u8fdb\u5165\u5230<\/span><span lang=\"en-US\">SetTextUI()<\/span><span lang=\"zh-CN\">\u65b9\u6cd5\u91cc\uff1b\u5728<\/span><span lang=\"en-US\">SetTextUI()<\/span><span lang=\"zh-CN\">\u91cc\uff0c\u9047\u5230<\/span><span lang=\"en-US\">yield return new WaitForSeconds(textSpeed);<\/span><span lang=\"zh-CN\">\u8bed\u53e5\u540e\u7b49\u5f85text<\/span><span lang=\"en-US\">Speed<\/span><span lang=\"zh-CN\">\u79d2\uff0c\u5728\u7ee7\u7eed\u6267\u884c\u4ee3\u7801\uff1b\u540c\u65f6\u5207\u6362\u8bf4\u8bdd\u4eba\u7269\u5934\u50cf\u7684\u529f\u80fd\u4e5f\u5728\u8be5\u65b9\u6cd5\u4e2d\u5b9e\u73b0\u3002<\/span><\/p>\n<\/li>\n<\/ul>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">using System.Collections;\nusing System.Collections.Generic;\nusing UnityEngine;\nusing UnityEngine.UI;\n\npublic class DialogSystem : MonoBehaviour\n{\n    [Header(\"UI\u7ec4\u4ef6\")]\n    public Text textLabel;\n    public Image faceImage;\n\n    [Header(\"\u6587\u672c\u6587\u4ef6\")]\n    public TextAsset textFile;\n    public int index;\n    public float textSpeed;\n    public Sprite faceA, faceB;\n\n    private List&lt;string> textList = new List&lt;string>();\n    private bool textFinished;\/\/\u5f53\u524d\u8fd9\u53e5\u8bdd\u8f93\u51fa\u5b8c\u4e86\u6ca1\n    private bool cancelTyping;\/\/\u662f\u5426\u7ed3\u675f\u9010\u4e2a\u5b57\u7b26\u663e\u793a\n\n    private void Awake()\n    {\n        \/\/\u6587\u672c\u6846\u5c31\u7eea\u524d\u5c06\u6587\u672c\u6587\u4ef6\u4e2d\u7684\u5185\u5bb9\u653e\u8fdbtextList\u4e2d\n        GetTextFromFile(textFile);\n    }\n\n    \/\/\u5f53\u6587\u672c\u6846\u5c31\u7eea\u540e\uff0c\u5c31\u663e\u793a\u7b2c\u4e00\u6761\u6587\u672c\n    private void OnEnable()\/\/\u4f1a\u6bd4Start\u5148\u8c03\u7528\n    {\n        StartCoroutine(SetTextUI());\n    }\n\n    private void Update()\n    {\n        \/\/\u5f53\u6309\u4e0bR\u952e\uff0c\u4e14\u6700\u540e\u4e00\u6761\u6587\u672c\u5df2\u7ecf\u5c55\u793a\u5b8c\uff0c\u5219\u5173\u95ed\u5bf9\u8bdd\u6846\uff0c\u91cd\u7f6eindex\n        if (Input.GetKeyDown(KeyCode.R) &amp;&amp; index == textList.Count)\n        {\n            gameObject.SetActive(false);\n            index = 0;\n            return;\n        }\n        \/\/\u5f53\u6309\u4e0bR\u952e\uff0c\u663e\u793a\u4e0b\u4e00\u6761\u6587\u672c\n        \/\/\u53ea\u6709\u8be5\u6761\u6587\u672c\u663e\u793a\u5b8c\u6bd5\u540e\u624d\u80fd\u663e\u793a\u4e0b\u4e00\u6761\uff0c\u4e0d\u7136\u4f1a\u4e71\u7801\uff08\u7528\u4e86\u534f\u7a0b\uff09\n        if (Input.GetKeyDown(KeyCode.R) &amp;&amp; textFinished)\n        {\n            StartCoroutine(SetTextUI());\/\/\u534f\u7a0b\n        }\n    }\n\n    \/\/\u5c06TextAsset\u6587\u4ef6\u6309\u7167\u6bcf\u4e00\u884c\u5207\u5272\u6210\u5b57\u7b26\u4e32\uff0c\u6dfb\u52a0\u8fdbtextList\u91cc\n    private void GetTextFromFile(TextAsset file)\n    {\n        textList.Clear();\n        index = 0;\n\n        \/\/\u5c06TextAsset\u6587\u4ef6\u6309\u7167\u6362\u884c\u5207\u5272\u6210\u5b57\u7b26\u4e32\n        \/\/windows\u6362\u884c\u7b26\u662f\\r\\n\uff0c\u518d\u53bb\u6389\u7a7a\u5143\u7d20\n        string[] lineDate = file.text.Split(new char[] { '\\r', '\\n' }, System.StringSplitOptions.RemoveEmptyEntries);\n\n\n        foreach (string line in lineDate)\n        {\n            textList.Add(line);\n        }\n    }\n\n    \/\/\u8ba9\u6587\u672c\u6846\u663e\u793a\u8ba9\u4e0b\u4e00\u6761\u6587\u672c\u7684\u6bcf\u4e2a\u5b57\u7b26\u6309\u5148\u540e\u987a\u5e8f\u663e\u793a\n    \/\/\u5e76\u663e\u793a\u8bf4\u8bdd\u89d2\u8272\u7684\u5934\u50cf\u56fe\u7247\n    IEnumerator SetTextUI()\n    {\n        textFinished = false;\n        \/\/\u56e0\u4e3a\u4e0b\u9762textLabel\u7684\u6587\u672c\u662f\u7d2f\u52a0\u6bcf\u4e2a\u5b57\u7b26\uff0c\u56e0\u6b64\u6bcf\u53e5\u8bdd\u4e4b\u524d\u8981\u5148\u6e05\u7a7a\n        textLabel.text = \"\";\n\n        \/\/\u5207\u6362\u6587\u672c\u6846\u8bf4\u8bdd\u4eba\u7269\u7684\u56fe\u7247\n        switch (textList[index])\n        {\n            case \"A\":\n                faceImage.sprite = faceA;\n                index++;  \/\/\u5b57\u7b26A\u3001B\u53ea\u7528\u6765\u5224\u65ad\u8be5\u663e\u793a\u4ec0\u4e48\u56fe\u7247\uff0c\u4e0d\u663e\u793a\u5728\u6587\u672c\u4e2d\n                break;\n            case \"B\":\n                faceImage.sprite = faceB;\n                index++;\n                break;\n        }\n        \/\/\u8ba9\u4e00\u53e5\u8bdd\u4e2d\u7684\u6bcf\u4e2a\u5b57\u7b26\u6309\u987a\u5e8f\u5148\u540e\u663e\u793a\n        for (int i = 0; i &lt; textList[index].Length; ++i)\n        {\n            textLabel.text += textList[index][i];\n\n            yield return new WaitForSeconds(textSpeed);\/\/\u7b49\u5f85textSpeed\u79d2\u540e\u7ee7\u7eed\n        }\n\n        textFinished = true;\n        index++;\n    }\n}<\/pre>\n\n\n\n<hr class=\"wp-block-separator is-style-wide\"\/>\n\n\n<h1><span style=\"font-family: 'Microsoft YaHei', 'Microsoft JhengHei', \u9ed1\u4f53; font-size: 24pt; color: #000000;\">\u76f4\u63a5\u663e\u793a\u5b8c\u6574\u53f0\u8bcd<\/span><\/h1>\n<p style=\"margin: 0in; font-family: 'Microsoft YaHei'; font-size: 14.0pt;\"><span lang=\"zh-CN\">\u8fd9\u4e00\u8282\u5c06\u4ecb\u7ecd\u5f53\u53f0\u8bcd\u8fd8\u5728\u5c55\u5f00\u8fc7\u7a0b\u4e2d\uff0c\u63d0\u524d\u6309\u4e0b<\/span><span lang=\"en-US\">R<\/span><span lang=\"zh-CN\">\u952e\uff0c\u76f4\u63a5\u663e\u793a\u5b8c\u6574\u53f0\u8bcd\u7684\u65b9\u6cd5\u3002<\/span><\/p>\n<p style=\"margin: 0in; font-family: 'Microsoft YaHei'; font-size: 14.0pt;\">\n<\/p><p style=\"margin: 0in; font-family: 'Microsoft YaHei'; font-size: 14.0pt;\"><span lang=\"zh-CN\">\u6211\u4eec\u76f4\u63a5\u4fee\u6539\u4e4b\u524d\u7684\u4ee3\u7801\uff0c\u6dfb\u52a0\u4e00\u4e2abool\u7c7b\u578b\u53d8\u91cfcancel<\/span><span lang=\"en-US\">Typing<\/span><span lang=\"zh-CN\">\u3002<\/span><\/p>\n<p style=\"margin: 0in; font-family: 'Microsoft YaHei'; font-size: 14.0pt;\"><span lang=\"zh-CN\">\u5e76\u5728<\/span><span lang=\"en-US\">Update()<\/span><span lang=\"zh-CN\">\u65b9\u6cd5\u4e2d\u6dfb\u52a0\u5224\u65ad<\/span><\/p>\n<ul>\n<li>\n<p style=\"margin: 0in; font-family: 'Microsoft YaHei'; font-size: 14.0pt;\"><span lang=\"zh-CN\">\u5f53\u73a9\u5bb6\u6309\u4e0b<\/span><span lang=\"en-US\">R<\/span><span lang=\"zh-CN\">\u952e\uff0c\u5982\u679ctext<\/span><span lang=\"en-US\">Finished<\/span><span lang=\"zh-CN\">\u4e3atrue\uff0c\u8bf4\u660e\u5f53\u524d\u53f0\u8bcd\u6ca1\u6709\u5728\u6253\u5370\u4e2d\uff0c\u76f4\u63a5\u542f\u7528\u534f\u7a0b\u6253\u5370\u4e0b\u4e00\u53e5\u53f0\u8bcd\u3002<\/span><\/p>\n<\/li>\n<li>\n<p style=\"margin: 0in; font-family: 'Microsoft YaHei'; font-size: 14.0pt;\"><span lang=\"zh-CN\">\u5982\u679ctextFinished\u4e3afalse\uff0c\u8bf4\u660e\u5f53\u524d\u53f0\u8bcd\u6b63\u5728\u6253\u5370\uff0c\u5219\u5c06cancel<\/span><span lang=\"en-US\">Typing<\/span><span lang=\"zh-CN\">\u7f6e\u4e3a<\/span><span lang=\"en-US\">true<\/span><span lang=\"zh-CN\">\u3002<\/span><\/p>\n<\/li>\n<\/ul>\n<p style=\"margin: 0in; font-family: 'Microsoft YaHei'; font-size: 14.0pt;\"><span lang=\"zh-CN\">\u5728\u534f\u7a0b\u51fd\u6570<\/span><span lang=\"en-US\">SetTextUI()<\/span><span lang=\"zh-CN\">\u65b9\u6cd5\u91cc\uff0c\u82e5\u68c0\u6d4b\u5230cancel<\/span><span lang=\"en-US\">Typing<\/span><span lang=\"zh-CN\">\u4e3atrue\uff0c\u5219\u8df3\u51fa\u6253\u5370\u5faa\u73af\uff0c\u5c06\u76ee\u524dtextList\u5143\u7d20\uff08\u5b57\u7b26\u4e32\uff09\u76f4\u63a5\u8d4b\u503c\u7ed9textLabel\u5c31\u5b9e\u73b0\u4e86\u8be5\u529f\u80fd\u3002<\/span><\/p>\n<p style=\"margin: 0in; font-family: 'Microsoft YaHei'; font-size: 14.0pt;\">\u4e3a\u4e86\u65b9\u4fbf\u201c\u8df3\u51fa\u6253\u5370\u5faa\u73af\u201d\u64cd\u4f5c\uff0c\u6211\u4eec\u5c06\u4e4b\u524d\u7684for\u5faa\u73af\u4fee\u6539\u4e3awhile\u5faa\u73af\u3002<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">using System.Collections;\nusing System.Collections.Generic;\nusing UnityEngine;\nusing UnityEngine.UI;\n\npublic class DialogSystem : MonoBehaviour\n{\n    [Header(\"UI\u7ec4\u4ef6\")]\n    public Text textLabel;\n    public Image faceImage;\n\n    [Header(\"\u6587\u672c\u6587\u4ef6\")]\n    public TextAsset textFile;\n    public int index;\n    public float textSpeed;\n    public Sprite faceA, faceB;\n\n    private List&lt;string> textList = new List&lt;string>();\n    private bool textFinished;\/\/\u5f53\u524d\u8fd9\u53e5\u8bdd\u8f93\u51fa\u5b8c\u4e86\u6ca1\n    private bool cancelTyping;\/\/\u662f\u5426\u7ed3\u675f\u9010\u4e2a\u5b57\u7b26\u663e\u793a\n\n    private void Awake()\n    {\n        \/\/\u6587\u672c\u6846\u5c31\u7eea\u524d\u5c06\u6587\u672c\u6587\u4ef6\u4e2d\u7684\u5185\u5bb9\u653e\u8fdbtextList\u4e2d\n        GetTextFromFile(textFile);\n    }\n\n    \/\/\u5f53\u6587\u672c\u6846\u5c31\u7eea\u540e\uff0c\u5c31\u663e\u793a\u7b2c\u4e00\u6761\u6587\u672c\n    private void OnEnable()\/\/\u4f1a\u6bd4Start\u5148\u8c03\u7528\n    {\n        \/\/textLabel.text = textList[index];\n        \/\/index++;\n        StartCoroutine(SetTextUI());\n    }\n\n    private void Update()\n    {\n        \/\/\u5f53\u6309\u4e0bR\u952e\uff0c\u4e14\u6700\u540e\u4e00\u6761\u6587\u672c\u5df2\u7ecf\u5c55\u793a\u5b8c\uff0c\u5219\u5173\u95ed\u5bf9\u8bdd\u6846\uff0c\u91cd\u7f6eindex\n        if (Input.GetKeyDown(KeyCode.R) &amp;&amp; index == textList.Count)\n        {\n            gameObject.SetActive(false);\n            index = 0;\n            return;\n        }\n        \/\/\/\/\u5f53\u6309\u4e0bR\u952e\uff0c\u663e\u793a\u4e0b\u4e00\u6761\u6587\u672c\n        \/\/\/\/\u53ea\u6709\u8be5\u6761\u6587\u672c\u663e\u793a\u5b8c\u6bd5\u540e\u624d\u80fd\u663e\u793a\u4e0b\u4e00\u6761\uff0c\u4e0d\u7136\u4f1a\u4e71\u7801\uff08\u7528\u4e86\u534f\u7a0b\uff09\n        \/\/if (Input.GetKeyDown(KeyCode.R) &amp;&amp; textFinished)\n        \/\/{\n        \/\/    \/\/textLabel.text = textList[index];\n        \/\/    \/\/index++;\n        \/\/    StartCoroutine(SetTextUI());\/\/\u534f\u7a0b\n        \/\/}\n\n        \/\/\u6309\u4e0bR\u952e\u540e\u8fdb\u884c\u5224\u65ad\n        \/\/\u5982\u679c\u663e\u793a\u4e0b\u4e00\u6761\u6587\u672c\u7684\u52a8\u4f5c\u5df2\u5c31\u7eea\uff0c\u5219\u5f00\u59cb\u9010\u4e2a\u5b57\u7b26\u663e\u793a\u53e5\u5b50\n        \/\/\u5982\u679c\u6b63\u5728\u9010\u4e2a\u5b57\u7b26\u663e\u793a\u53e5\u5b50\uff0c\u5219\u5c06cancelTyping\u8bbe\u7f6e\u4e3atrue\u2014\u2014\n        \/\/\u8868\u793a\u53d6\u6d88\u9010\u4e2a\u5b57\u7b26\u663e\u793a\uff0c\u76f4\u63a5\u663e\u793a\u8be5\u6761\u6240\u6709\u5b57\u7b26\n        if(Input.GetKeyDown(KeyCode.R))\n        {\n            if(textFinished &amp;&amp; !cancelTyping)\n            {\n                StartCoroutine(SetTextUI());\n            }\n            else if(!textFinished &amp;&amp; !cancelTyping)\n            {\n                cancelTyping = true;\n            }\n        }\n    }\n\n    \/\/\u5c06TextAsset\u6587\u4ef6\u6309\u7167\u6bcf\u4e00\u884c\u5207\u5272\u6210\u5b57\u7b26\u4e32\uff0c\u6dfb\u52a0\u8fdbtextList\u91cc\n    private void GetTextFromFile(TextAsset file)\n    {\n        textList.Clear();\n        index = 0;\n\n        \/\/\u5c06TextAsset\u6587\u4ef6\u6309\u7167\u6362\u884c\u5207\u5272\u6210\u5b57\u7b26\u4e32\n        \/\/windows\u6362\u884c\u7b26\u662f\\r\\n\uff0c\u518d\u53bb\u6389\u7a7a\u5143\u7d20\n        string[] lineDate = file.text.Split(new char[] { '\\r', '\\n' }, System.StringSplitOptions.RemoveEmptyEntries);\n\n\n        foreach(string line in lineDate)\n        {\n            textList.Add(line);\n        }\n    }\n\n    \/\/\u8ba9\u6587\u672c\u6846\u663e\u793a\u8ba9\u4e0b\u4e00\u6761\u6587\u672c\u7684\u6bcf\u4e2a\u5b57\u7b26\u6309\u5148\u540e\u987a\u5e8f\u663e\u793a\n    \/\/\u5e76\u663e\u793a\u8bf4\u8bdd\u89d2\u8272\u7684\u5934\u50cf\u56fe\u7247\n    IEnumerator SetTextUI()\n    {\n        textFinished = false;\n        \/\/\u56e0\u4e3a\u4e0b\u9762textLabel\u7684\u6587\u672c\u662f\u7d2f\u52a0\u6bcf\u4e2a\u5b57\u7b26\uff0c\u56e0\u6b64\u6bcf\u53e5\u8bdd\u4e4b\u524d\u8981\u5148\u6e05\u7a7a\n        textLabel.text = \"\";\n\n        \/\/\u5207\u6362\u6587\u672c\u6846\u8bf4\u8bdd\u4eba\u7269\u7684\u56fe\u7247\n        switch(textList[index])\n        {\n            case \"A\":\n                faceImage.sprite = faceA;\n                index++;  \/\/\u5b57\u7b26A\u3001B\u53ea\u7528\u6765\u5224\u65ad\u8be5\u663e\u793a\u4ec0\u4e48\u56fe\u7247\uff0c\u4e0d\u663e\u793a\u5728\u6587\u672c\u4e2d\n                break;\n            case \"B\":\n                faceImage.sprite = faceB;\n                index++;\n                break;\n        }\n        \/\/\u8ba9\u4e00\u53e5\u8bdd\u4e2d\u7684\u6bcf\u4e2a\u5b57\u7b26\u6309\u987a\u5e8f\u5148\u540e\u663e\u793a\n        \/\/for(int i=0;i&lt;textList[index].Length;++i)\n        \/\/{\n        \/\/    textLabel.text += textList[index][i];\n\n        \/\/    yield return new WaitForSeconds(textSpeed);\/\/\u7b49\u5f85textSpeed\u79d2\u540e\u7ee7\u7eed\n        \/\/}\n\n        \/\/\u8ba9\u4e00\u53e5\u8bdd\u4e2d\u7684\u6bcf\u4e2a\u5b57\u7b26\u6309\u987a\u5e8f\u5148\u540e\u663e\u793a\n        \/\/\u82e5cancelTyping\u4e3atrue\uff0c\u5219\u8df3\u51fa\uff0c\u663e\u793a\u8be5\u6761\u6587\u672c\u6240\u6709\u5b57\u7b26\n        int letter = 0;\n        while (!cancelTyping &amp;&amp; letter &lt; textList[index].Length)\n        {\n            textLabel.text += textList[index][letter];\n            letter++;\n            yield return new WaitForSeconds(textSpeed);\/\/\u7b49\u5f85textSpeed\u79d2\u540e\u7ee7\u7eed\n        }\n        if (cancelTyping)\n        {\n            textLabel.text = textList[index];\n            cancelTyping = false;\n        }\n\n        textFinished = true;\n        index++;\n    }\n}<\/pre>\n\n\n\n<hr class=\"wp-block-separator is-style-wide\"\/>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[],"class_list":["post-782","post","type-post","status-publish","format-standard","hentry","category-unity3d"],"_links":{"self":[{"href":"https:\/\/summid.icu\/index.php\/wp-json\/wp\/v2\/posts\/782","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/summid.icu\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/summid.icu\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/summid.icu\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/summid.icu\/index.php\/wp-json\/wp\/v2\/comments?post=782"}],"version-history":[{"count":14,"href":"https:\/\/summid.icu\/index.php\/wp-json\/wp\/v2\/posts\/782\/revisions"}],"predecessor-version":[{"id":803,"href":"https:\/\/summid.icu\/index.php\/wp-json\/wp\/v2\/posts\/782\/revisions\/803"}],"wp:attachment":[{"href":"https:\/\/summid.icu\/index.php\/wp-json\/wp\/v2\/media?parent=782"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/summid.icu\/index.php\/wp-json\/wp\/v2\/categories?post=782"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/summid.icu\/index.php\/wp-json\/wp\/v2\/tags?post=782"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}