Visual Studio Code 配合 Unity3D

  • 2017.7.13 更新支持 .lua.txt 語法高亮

官方參考

windows

需要安裝

Microsoft .NET Core
Microsoft .NET Framework 3.5 SP1

ps: .NET Framework 3.5 安裝時(shí)需要保證 window update 開啟。否則更新不成功。window10 下開啟 window update 方法:按 WIN + r 打開運(yùn)行,輸入 services.msc 回車。找到 “Windows update”。

OSX

需要安裝

Mono 跨平臺(tái)的 .NET 框架。
homebrew: 打開終端執(zhí)行 /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
dotnet cli

ps: 后來發(fā)現(xiàn)安裝 homebrew 是為了更好地安裝 dotnet cli。

通用

使用 VSCode 寫 Unity 時(shí),需要為 每一個(gè) unity 項(xiàng)目單獨(dú)配置一下,在項(xiàng)目的 Assets 目錄下新建 Plugins/Editor 文件夾,將下載的 VSCode.cs 腳本文件放到這個(gè)目錄下。重啟一下 Unity。在 Preferences... 中(OSX 下的 Unity 選項(xiàng)卡,Windows 下的Edit選項(xiàng)卡)。

Z5(`{E9{L%WLRPE(85}0V_E.png

勾選六項(xiàng)。再次開啟 unity 時(shí)就會(huì)自動(dòng)啟動(dòng) VSCode。根據(jù) VSCode 控制臺(tái)的(報(bào)錯(cuò))信息 。去下載上方提到的幾種前置。

支持 .lua.txt

  1. 安裝 lua 擴(kuò)展
  2. 在設(shè)置中添加配置項(xiàng)
// 首選項(xiàng) - 設(shè)置 - settings.json
{
  // ...
  "files.associations": {
    "*.lua.txt": "lua"
  }
}

windows 如果雙擊文件不打開 vscode,嘗試勾選掉 Unity Preferences/VSCode 中的 enable Integration

插件

  • C#:VSCode 下的 C# 語法支持
  • Unity Snippets: 提供一些語法片段
  • C# Extensions: 語法快捷擴(kuò)展

設(shè)置

// settings.json
{
  "editor.fontSize": 18,
  "editor.tabSize": 2,
  "editor.wordWrap": "on",
  "editor.minimap.enabled": true,
  "editor.rulers": [ 80, 100 ],
  // "editor.renderWhitespace": "boundary",

  "files.autoGuessEncoding": true,
  "files.autoSave": "onWindowChange",
  "files.defaultLanguage": "zh-cn",

  "markdown.preview.fontSize": 18,
  "extensions.autoUpdate": true,

  "workbench.colorTheme": "Material Theme",
  "workbench.iconTheme": "vs-seti"
}

## 異常問題

1. 編輯器啟動(dòng)報(bào)錯(cuò):OmniSharp.MSBuild.ProjectFile.ProjectFileInfo The reference assemblies for framework ".NETFramework,Version=v2.0" were not found.
電腦中包含多個(gè)版本的 mono
解決方案:`brew unlink mono; brew link mono`,
慘嚎鏈接:https://github.com/OmniSharp/omnisharp-vscode/issues/1004
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容