Skip to main content

VS Code

To use TypeScript in a Unity project, it is required to use an IDE (Integrated Development Environment) to write the code in. It is highly recommended to use VS Code because it has Genies tools for autocomplete, debugging, and much more.

Setting Up

Download VS Code

Download the latest version of VS Code here: https://code.visualstudio.com/

Extensions

In VS Code, open the left side Extensions tab. Install the Unity and TypeScript extensions for VS Code.

Extensions

Set the TypeScript Version

VS Code will not recognize all of the TypeScript syntax settings unless you choose the correct version of TypeScript.

Follow these steps:

  1. In VS Code, open the Unity project folder by selecting File > Open Folder.
  2. At the top input field, type > TypeScript: Select TypeScript Version.
  3. Select the second option named Use Workspace Version from the dropdown menu.

TypeScript Workspace

Set the Default Script Editor

In Unity, select from the top menu dropdown Edit > Preferences. In the External Tools section, make sure Visual Studio Code is selected as the default External Script Editor. This will open up VS Code when double clicking script files in Unity.

External Tools

Next Steps

tip

Check out the Hello World example to make sure TypeScript is working.

Tips and Tricks

Debugging

Check out the Debugging with VS Code page for more information.

Autocomplete Lifecycle Events

You can autocomplete lifecycle events when you begin typing the names.

Autocomplete Lifecycle

Autocomplete Package Imports

You can autocomplete importing a package when you begin typing the package names. You can also click on the unrecognized package name and then click the blue lightbulb on the left to add the import.

Autocomplete Import