
This article is my memo for creating a comfortable development environment with Unity + VSCode.
Softwre | Version |
---|---|
Unity | Unity2020.3 LTS |
OS | Windows 10 Home |
VSCode | 1.63.2 |
For Unity, install the stable version (LTS) unless you have a specific reason not to.
VSCode can also be downloaded and installed from the following link.
It can also be installed from package management tools such as Chocolatey.
Switch the standard editor to "VSCode" when you select a script in Unity or when you open a project.Switch the standard editor to "VSCode".
In Unity, select
-> and press
From the left side of the Preferences window, set Visual Studio Code
.
Open the current Unity project with VSCode.
-> to open it in VS Code.
Unity + VSCode alone is still inconvenient for coding.
To make the development process more efficient, the following extension plug-ins should be installed.
The following are the extension plugins that I installed for VSCode.
Plugin Name | Summury |
---|---|
C# for Visual Studio Code | It complements C# coding on VSCode. |
Debugger for Unity | Debuggable with breakpoints, etc. when run in Unity |
Unity Code Snippets | Frequently used code in Unity can be easily generated with code completion. |
c# XML Documentation Comments | It completes the description of comments when coding C# on VSCode. |
All of them can be installed immediately as plug-ins from "Extensions" of VSCode.
Below is a brief description of the main points of each extension plug-in.
NET Core or Mono, it will be able to support C# coding running on .
NET Core or Mono. You can use
+ to complete the following in pre-written code.
Using .NET Framework in VSCode Although not directly related to Unity, VSCode is not suitable for development using the old-fashioned Windows Native features . (NET Framework (although it's not impossible). NET Framework, it is better to use Microsoft Visual Studio Community instead of VSCode, as it has better code completion and debugging for related libraries.
It is possible to place breakpoints in the code on VSCode (a useful feature to temporarily stop execution and check the contents of variables, etc.).
You can put a breakpoint by
on the left side of where you want to stop in the code.You can run Unity, stop at the line of the breakpoint, and see what happens to the contents of the variable a.
In order to actually stop at a breakpoint, we need to specify from VSCode which Unity Editor we want to associate with it.
Open the VSCode command palette with Unity Attach Debugger
".
If you have more than one Unity Editor running, you will see a selection.
When the debugger is connected to the Unity Editor, the following information for debugging will be displayed on VSCode.
You can also debug on the Unity side! message will be displayed.
The actual way to put breakpoints and debug is omitted(maybe another article).
For Unity related libraries, you will be able to use templating code that need to be created in a standardized way.
For example, if you create a new .cs script and type Mono
,
"MonoBehaviour" will appear in the code completion list, as shown below.
If you complete the code in this state, you will see
This is the template for a class that inherits from MonoBehaviour, which is the base class for creating Unity components. which is the base class for creating Unity components (commonly referred to as boilerplate).
In addition to this, you can also use the
If you type "Start
" in a class that inherits from MonoBehaviour, it will generate the necessary template-like methods as shown below.
You can also use the completion function to generate the code for Unity's log output, which is often used.
When commenting in C# coding, it completes the required template.
For example, if you put the comment "///
" just before the definition like this
It will automatically generate a comment insertion template as follows.
This is so useful!
It will also generate the necessary comment templates for the methods.
If you type "///
" just before a code like the following
It will also generate templates with arguments and return values as shown below.
If the code does not complete properly, please refer to the following article, which may help!
date | modification |
---|---|
none |
Thank you for your message.
Sorry. The Error has occurred.We apologize for the inconvenience.Please try again in a few minutes or contact us via DM below.
Twitter:@NodachiSoft_engName:Send the following information to us. If you are happy with your submission, please click "Send". If you want to modify it, please click "Back".
Name: