Sunday, July 12, 2020

UE4: Using Visual Studio Code for UE4 c++ project

It's possible to get UE4 to work with Visual Studio Code without installing Visual Studio.

My setup:
  • Windows 10
  • Visual Studio Code 1.47.0
  • Unreal Engine 4.24.2
Install Build Tools for Visual Studio
From the Visual Studio Downloads page, scroll down until you see Tools for Visual Studio under the All downloads section and select the download for Build Tools for Visual Studio.

Open vs_BuildTools.exe. Under Workloads, select C++ build tools. On the right, make sure to keep the optional component MSVC vXXX - VS 2019 C++ x64/x86 build tools and Windows 10 SDK checked. You can uncheck Testing tools core features - Build Tools and C++ AddressSanitizer (Experimental) to save some space.

Under Workloads, select .Net desktop build tools. You can uncheck all the optional components to save ~1.68 GB. You will be prompted to reboot once the installation is completed.

Change default editor to Visual Studio Code
Open UE4, you should now be able to create a new c++ game project. Once the project is generated, open UE4 and go to Edit > Editor Preferences.... Under General > Source Code, change Source Code Editor to Visual Studio Code. Then restart UE4.

Generate Visual Studio Code project files
Now when you right-click on your .uproject in Windows Explorer, Generate Visual Studio project files should now create MyProject.code-workspace for Visual Studio Code.

Configure build task in Visual Studio Code
In Visual Studio Code, install the c++ extension if you haven't already. To configure the build task, go to Terminal > Configure Default Build Task..., select MyProjectEditor Win64 Development Build. Press Ctrl + Shift + B to build the project, and hot reload should work as expected.


Ref:
Configure Visual Studio Code for Microsoft C++

No comments: