Visual Studio Tools for UnityVisual Studio Tools for Unity

Visual Studio Tools for Unity


Visual Studio Tools for Unity 是一種免費的 Visual Studio 延伸模組,可將 Visual Studio 轉換為使用 Unity 開發跨平台遊戲和應用程式的功能強大工具。Visual Studio Tools for Unity is a free Visual Studio extension that turns Visual Studio into a powerful tool for developing cross-platform games and apps with Unity.

Unity 編輯器適合用來組合您的遊戲世界,但無法在該編輯器中撰寫程式碼。While the Unity editor is great for putting your game world together, you can't write your code in it. 您可運用 Visual Studio Tools for Unity,使用熟悉的 Visual Studio 程式碼編輯、偵錯與提升生產力的功能,用 C# 為 Unity 專案建立編輯器與遊戲指令碼,也可以使用 Visual Studio 的強大偵錯功能,對這些指令碼進行偵錯。With Visual Studio Tools for Unity, you can use the familiar code editing, debugging and productivity features of Visual Studio to create editor and game scripts for your Unity project using C#, and you can debug them using Visual Studio's powerful debugging capabilities.

不僅如此,Visual Studio Tools for Unity 還與 Unity Editor 緊密整合,因此您可以花較少時間來回切換執行簡單工作,它也提供 Unity 特有的提升產能功能,並將 Unity 文件放在您可以隨時取得的位置。But Visual Studio Tools for Unity is more than that; it also has deep integration with Unity editor so that you'll spend less time switching back and forth to do simple tasks, provides Unity-specific productivity enhancements, and puts the Unity documentation at your fingertips.

與 Windows 和 macOS 上的 Visual Studio Community 相容,並與 Unity 配套Compatible with Visual Studio Community on Windows and macOS and bundled with Unity

Visual Studio 和 Visual Studio for Mac 的社區都可免費使用,並與 Unity 安裝配套。Visual Studio and Visual Studio for Mac Community is available for free, and is bundled with Unity installs. 如需安裝和設定的詳細資訊,請造訪 Visual Studio Tools for Unity 使用者 入門檔Visit the Visual Studio Tools for Unity getting started documentation for more information about installation and setup.

Unity 訊息的 IntelliSenseIntelliSense for Unity messages

IntelliSense 程式碼編譯可快速且輕鬆地實作 Unity API 訊息 (例如 OnCollisionEnter),包含其參數。IntelliSense code-completion makes it fast and easy to implement Unity API messages like OnCollisionEnter, including their parameters.

顯示 OnCollisionEnter 的 IntelliSense 對話方塊

高階偵錯Superior debugging

Visual Studio Tools for Unity 支援預期從 Visual Studio 取得的強大偵錯功能:Visual Studio Tools for Unity supports the robust debugging features that you expect from Visual Studio:

  • 設定中斷點,包含條件式中斷點。Set breakpoints, including conditional breakpoints.
  • 在監看式視窗中評估複雜的運算式。Evaluate complex expressions in the Watch window.
  • 檢查及修改變數和引數的值。Inspect and modify the value of variables and arguments.
  • 向下切入至複雜的物件和資料結構。Drill down into complex objects and data structures.


最佳做法與效能深入解析的整合建議Integrated suggestions for best practices and performance insights

撰寫更好的程式碼,利用 Visual Studio 對 Unity 專案的深入瞭解,來取得最佳做法。Write better code that captures the best practices with Visual Studio's deep understanding of Unity projects.

VS 重構字串與 CompareTag 的比較

Unity 腳本和訊息的 CodeLens 支援CodeLens support for Unity scripts and messages

Unity 腳本和訊息函式是以提示裝飾,可讓您更輕鬆地辨識 Unity 所提供的內容,以及您的程式碼。Unity scripts and message functions are decorated with hints to make it easier to recognize what's provided by Unity and what's your code.

新的腳本,顯示 Unity 腳本和 Unity 訊息的 CodeLens 提示


CodeLens 支援可在 Visual Studio 2019 中取得。CodeLens support is available in Visual Studio 2019.

優化所有腳本的視圖以符合 UnityOptimized view of all your scripts to match Unity

Unity Project Explorer (UPE) 是透過標準方案總管來查看專案檔的替代方法。The Unity Project Explorer (UPE) is an alternative way to view you project files over the standard Solution Explorer. UPE 會篩選所顯示的檔案,並將它們顯示在符合 Unity ( View > Unity Project Explorer 的階層中 Visual Studio 2019) 。The UPE filters the files shown and presents them in a hierarchy that matches Unity ( View > Unity Project Explorer in Visual Studio 2019).

Unity Project Explorer


Unity Project Explorer 可在 Visual Studio 2019 中取得。The Unity Project Explorer is available in Visual Studio 2019. 在 Visual Studio for Mac 中,Solution Pad 預設會有 Unity 專案的類似行為-不需要額外的視圖。In Visual Studio for Mac, the Solution Pad has similar behaviour by default for Unity projects - no additional views are required.