Unreal C++ with Visual Studio Code

By November 2, 2018Development, Tutorial

In the spirit of show casing alternative ways of working with Unreal and C++ I wanted to share with you guys how to use Visual Studio Code as your primary IDE.

Visual Studio Code is a fairly lean IDE based on the Electron framework that was designed to tap into the market of Sublime, Atom, etc etc but it works just fine as a C++ editor.

Similar to my earlier post there are a few prerequisites you need to have available / installed to follow this tutorial:

  • Ensure that you either have Visual Studio Community 2017  installed or alternatively just the Visual Studio Build Tools as you need something to still compile the code.
    • Visual Studio Code will recognize what you have these packages installed and assign the correct compiler configurations
  • Unreal Engine 4.20.3
  • Visual Studio Code
  • Windows 10

Once you have these pieces installed, let’s move onto the Unreal Editor configuration

  • Open Unreal Editor ( source or binary doesn’t matter )
  • Go to Edit -> Editor Preferences

  • Then go to General -> Source Code -> Source Code Editor and select Visual Studio Code

  • Once this is done you should now be able to generate a new Visual Studio Code project  using File -> Generate Visual Studio Code Project

  • This generation step will take a few seconds to complete
  • To open up Visual Studio Code go to File -> Open Visual Studio Code

You should now be able to see the IDE getting launched from Unreal and your project available for compilation.

The only other thing you need to be aware of is how to get at the build targets.

To do so you can go to Terminal -> Run Build Task or simply hit CTRL + SHIFT + B

That’s it !

You are now setup to use Visual Studio Code.

 

 

Additional Information

The only other thing you may want to setup within Visual Studio Code are a number of plugins that assist with intellisense, auto complete, etc etc

Here is a list of plugins I currently have configured:

Deleting Visual Studio Code references and changing back to a different editor

In case you are not happy with Visual Studio Code and want to revert things back to use Visual Studio I recommend cleaning up the files the VS Code integration generated.

Specifically the following folders / files inside of your root project:


.vscode/
[PROJECTNAME].code-workspace

Once this is complete you simply follow the initial set of instructions but instead of picking VS Code just select Visual Studio 2015/2017. This should then give you the option to re-generate the Visual Studio project within Unreal Editor ( File -> Refresh / Generate Visual Studio Project )

8 Comments

  • Raja Akel says:

    Hello, i had a problem downloading Unreal engine 4
    When running it it immediately crashes with error 0xc000007b “Application stopped working”. That’s allit gives me. Any ideas on how to fix it?
    Thanks

  • Lucas says:

    Hi, were you able to step through engine code with your setup?

    For me, every time vscode tries to open an engine file I’ll get something like “Unable to open ”: File not found (file:///d:/build/++ue4/sync/engine/).”

    • admin says:

      Hmm I cannot say I have this problem. Are you opening visual studio code from the Unreal Editor ? Have you tried checking out if you have plugins that are conflicting maybe ? Do you perhaps need to install the various plugins ( c++ / unreal snippets ) ? Perhaps try regenerating the project files. Perhaps if you have any errors we can see what else can be done.

      If it helps I am running Unreal 4.20 and 4.21 both seem to work. While Visual Studio Code is version 1.28.2. Here is a quick screenshot of the Engine.h file for example. https://i.imgur.com/YtfsJ1O.png

  • Peter Turner says:

    Thanks for this post!
    Wanted to get back into Unreal and things have changed slightly since a few years ago so certainly saved me a lot of time to switch from Visual Studio to VSCode which is my current editor of choice for Golang/Python etc

    It’s good to good to see it so well integrated though I doubt I’d ever have imagined it could be possible like this without your help!

    Cheers from London

  • Gyuyoul says:

    Hi, Thanks for this post!
    I can setup project with visual studio code after reading this article. and Build is successful.
    But whenever I hit F5 key to debug, code always shows me this error, “ERROR: Missing precompiled manifest for ‘Launch’. This module was most likely not flagged for being included in a precompiled build – set ‘PrecompileForTargets = PrecompileTargetsType.Any;’ in Launch.build.cs to override.”.
    Can you give me an idea to solve this problem?

Leave a Reply