pc8888888 发表于 2021-10-29 08:52

vscode tolua 代码提示

vscode lua.rar
安装 jdk 1.8.0 并配置环境变量
把 emmylua-unity-1.0.3.vsix 复制到 VSCode 的 bin目录下
按住 Shift 右键 在此处打开 PowerShell 窗口,执行下面命令
code --install-extension emmylua-unity-1.0.3.vsix
安装好后打开vscode 安装emmyLua
安装完成记得重启
vscode 打开unity 的lua目录,空目录也行
把EmmyLuaService.cs丢到unity项目的Editor文件夹下
编译后 选择菜单 EmmyLua 的Enable,启动提示服务
返回vscode 在工作区 右键 pull unity api 等待拉取完成
之后代码就有提示了
栗子:
local GameObject = UnityEngine.GameObject;
local Resources = UnityEngine.Resources;
local prefab = Resources.Load("cube");
local cube = GameObject.Instantiate(prefab);你会发现cube:后面并没有gameobject函数的提示
你可以在上面添加类型提示
local GameObject = UnityEngine.GameObject;
local Resources = UnityEngine.Resources;
local prefab = Resources.Load("cube");

---@type UnityEngine.GameObject
local cube = GameObject.Instantiate(prefab);
cube:AddComponent(typeof(UnityEngine.Rigidbody))
页: [1]
查看完整版本: vscode tolua 代码提示