搭建UnLua开发环境和调试-VSCode
<p>[TOC]</p>
<h1>智能提示</h1>
<p>参考文档:[UnLua智能提示](<a href="https://github.com/Tencent/UnLua/blob/develop/Docs/CN/IntelliSense.md">https://github.com/Tencent/UnLua/blob/develop/Docs/CN/IntelliSense.md</a> "UnLua智能提示")</p>
<p>VSCode Lua智能提示插件:<strong>LuaPanda</strong>
<img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=c635aeb21c21884906818197246b0274&amp;file=file.png" alt="" /></p>
<h2>1. 生成智能提示</h2>
<p>打开UnLua工具栏,点击导出智能提示,会在{UE工程}/Plugins/UnLua/Intermediate下生成IntelliSense的目录
若蓝图或C++代码有更新,需重新生成
<img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=ab0e7351ea813a43cb89363f0dc6caf2&amp;file=file.png" alt="" /></p>
<h2>2. 添加智能提示文件夹到VSCode工作区</h2>
<p><img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=3eefbeee2e2f69a114dec25cbf52ff3d&amp;file=file.png" alt="" /></p>
<h2>3. 验证智能提示信息是否工作</h2>
<p><img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=088602a18f919a07e16242af71052a2f&amp;file=file.png" alt="" /></p>
<h1>调试</h1>
<p>VSCode Lua调试插件:<strong>LuaPanda</strong></p>
<p>参考教程:[UE教程】配置Unlua调试环境 分享](<a href="https://www.bilibili.com/video/BV1Jf421Q7tg/?spm_id_from=333.337.search-card.all.click&vd_source=7eae1e20c9e58607091ff5032af4f20e">https://www.bilibili.com/video/BV1Jf421Q7tg/?spm_id_from=333.337.search-card.all.click&vd_source=7eae1e20c9e58607091ff5032af4f20e</a> "UE教程】配置Unlua调试环境 分享")</p>
<p>教程文档链接:[Unlua调试环境配置](<a href="https://flowus.cn/share/f2502144-9354-4b8a-ae0b-2d6ddf1d412e?code=CQMXSA">https://flowus.cn/share/f2502144-9354-4b8a-ae0b-2d6ddf1d412e?code=CQMXSA</a> "Unlua调试环境配置")</p>
<h2>1. 迁移LuaPanda.lua</h2>
<p>LuaPanda.lua可使用Everything搜索
<img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=93fb0ff977dab2ca0783ca2e458a7aa2&amp;file=file.png" alt="" /></p>
<p>拷贝LuaPanda.lua至项目Lua根目录,默认为\Content\Script</p>
<h2>2. 配置LuaPanda launch.json</h2>
<p><img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=84b6889d180556e2c779324900fbe3f2&amp;file=file.png" alt="" /></p>
<p>stopOnEntry改为false
<img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=945eade356aed317563c0f3fd66a2ce7&amp;file=file.png" alt="" /></p>
<h2>3. 修改需要调试的lua文件</h2>
<p>需要调试的lua文件开头加上这两行代码
<strong>注意socket目录改为自己电脑上的</strong></p>
<pre><code class="language-lua">package.cpath = package.cpath .. &quot;;D:/VLabGit/vlab/virtual-lab-unreal/UnLua Debug/socket/?.dll&quot;
require(&quot;LuaPanda&quot;).start(&quot;127.0.0.1&quot;,8818)</code></pre>
<p><img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=4f2b7e2fef0708a83c21357bae395db3&amp;file=file.png" alt="" /></p>
<h2>4. 附加断点,运行UE调试</h2>
<p><img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=48dd3cdc26c6269a34246239ebc5e35c&amp;file=file.png" alt="" /></p>
<h1>附:如何生成调试文件</h1>
<h2>1. 使用Visual Studio创建C++空项目</h2>
<p><img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=2a018b4b6db380bc40a02f089b1d40cd&amp;file=file.png" alt="" /></p>
<h2>2. 导入UnLua官方Lua源码</h2>
<p><img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=55b96754bd86d470254ad3c4ff687baa&amp;file=file.png" alt="" /></p>
<p>若需修改Lua版本可在 <a href="https://www.lua.org/versions.html">https://www.lua.org/versions.html</a> 下载</p>
<h2>3. 配置项目生成lib</h2>
<p><img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=2c484735bbc0b97794a9cb39727b6755&amp;file=file.png" alt="" /></p>
<h2>4. 编译生成得到lua54.lib文件</h2>
<p><img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=770746c9310c090c6182a2763be9acb2&amp;file=file.png" alt="" /></p>
<h2>5. 打开luasocket.sln</h2>
<p>LuaSocket下载地址:<a href="https://github.com/lunarmodules/luasocket/releases">https://github.com/lunarmodules/luasocket/releases</a></p>
<p>直接点确定就好
<img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=c1cd6feb839d6cb1725c12681854dfdc&amp;file=file.png" alt="" /></p>
<h2>6. 修改socket项目库目录</h2>
<p>库目录地址为第4步编译生成的lua54.lib所在目录
<img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=7d24e3500fddf9ee4d3246f3274f8f1c&amp;file=file.png" alt="" /></p>
<h2>7. socket项目关联Lua源码</h2>
<p>Lua源码目录与第2步中一致
<img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=8523b3e2d84bc5e4b2e99794968260cc&amp;file=file.png" alt="" /></p>
<h2>8. 编译socket项目</h2>
<p>有此报错,将Lua.props中的5.3改为5.4
<img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=bb17bd44b0851ffa4b1703de3267ad75&amp;file=file.png" alt="" /></p>
<p><img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=9660c952e0e919b66f975b6a2a0ae4b7&amp;file=file.png" alt="" /></p>
<h2>9. 迁移编译出的文件到项目根目录</h2>
<p>socket项目编译目录
<img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=8df148b531d9e96f8b7173aa1fc97ccb&amp;file=file.png" alt="" /></p>
<p>项目根目录
<img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=193ceac075f79593c85bf0462496c15e&amp;file=file.png" alt="" /></p>