November 14th, 2023

Unreal Engine and C++ Game Development Made Easy with Visual Studio 2022

David Li
Game Dev Product Manager

Introduction

A Sea of Thieves character on a boat. There are Sea of Thieves, Unreal Engine and Visual Studio logos.

Creating amazing games just got easier. We are very happy to announce the latest Unreal Engine integrations and powerful C++ productivity features in Visual Studio 2022. Our team has been tirelessly working to incorporate your feedback and bring even more features that will enhance your game development experience whether you work on Unreal Engine or a proprietary engine.

In this blog, we will explore how you can leverage the new Unreal Engine Test Adapter, which helps to streamline your testing process without leaving the IDE. Then, we will also show you how you can code faster with Unreal Engine snippets and macro specifier suggestions, as well as view in-memory bitmaps. Next, we have included a range of core C++ productivity features and debugger enhancements that will benefit not only those working on Unreal Engine but also anyone who works on their own engines. Lastly, we will round out the blog with updates on C++ IntelliSense and debugger launch performance improvements.

Most of these productivity features are available in Visual Studio 2022 version 17.8, while some are available in the latest previews. We are confident that these features will help you be more productive and enable you to create even more amazing games.

Latest Unreal Engine Integrations

Setting Up Unreal Engine Integrations

Unreal Engine integrations will only show up when you are working on an Unreal Engine project. To ensure these features are active, double check that the “IDE support for Unreal Engine” component is enabled in the “Game development for C++” workload in the Visual Studio Installer. Some integrations such as Blueprints support and Test Adapter will require the free “Visual Studio Integration Tool” Unreal Engine Plugin. Please see Visual Studio Tools for Unreal Engine for detailed setup instructions.

The screenshot of the Game development with C++ workload in the Visual Studio Installer with "IDE support for Unreal Engine" checked.

Unreal Engine Test Adapter

Special thanks to the folks at Rare who contributed tremendously to this feature.

Streamline your testing process without leaving the IDE with Unreal Engine Test Adapter. You can now discover, run, manage, and debug your Unreal Engine tests. In Visual Studio 2022 version 17.8, you will automatically see your Unreal Engine Tests when you open Visual Studio. To see your tests, you can open Test Explorer with View > Test Explorer.

A screenshot of the Test Explorer window in Visual Studio loaded with Unreal Engine tests

The latest version of our free Visual Studio Tools for Unreal Engine plugin is required to use Unreal Engine Test Adapter. In addition, ensure the “Unreal Engine Test Adapter” component in the “Game development with C++” workload is enabled in the Visual Studio Installer.

A screenshot of the Visual Studio Installer. Unreal Engine Test Adapter under Game development with C++ is circled.

Unreal Engine Code Snippets

Write code more efficiently with Unreal Engine Code Snippets. In Visual Studio 2022 version 17.8, you can find common Unreal Engine constructs as snippets in your member list. To begin, enter the name of any Unreal Engine construct, such as “uclass”. Then, press Tab or Enter to expand the snippet.

A screenshot of a UCLASS Unreal Engine snippet in Visual Studio

We have also included exported versions of UCLASS (uclass, uclassexported), UINTERFACE (uinterface, uinterfaceexported), and USTRUCT (ustruct, ustructexported) for those working with exported APIs and plugins. In addition, we have included macros such as SWidget (swidget), TActorRange (tactorrange), TObjectRange (tobjectrage), and WITH_EDITOR (witheditor) based on your feedback.

List of Supported Snippets

uclass
uclassexported
uenum
ufunction
uinterface
uinterfaceexported
uproperty
ustruct
ustructexported
uelog
swidget
tactoreange
tobjectrange
witheditor

 

Image Watch Support for Unreal Engine Projects

A screenshot of the image watch extension showing an in-memory bitmap

We are excited to announce that Image Watch for Visual Studio 2022 now supports Unreal Engine’s FImage type. Image Watch is an extension that makes it easier than ever for you to view in-memory bitmaps while debugging C++ code. This is an essential tool for anyone working with images in C++. Be sure to try out the extension today.

A Gif showcasing Image Watch with Unreal Engine Projects

Unreal Engine Macro Specifier IntelliSense

In the coming weeks, Unreal Engine developers will gradually gain access to this experimental feature in the Visual Studio 2022 version 17.8.

One of the top feedback items we commonly receive is suggesting Unreal Engine macro specifiers. We are happy to share that macro specifiers will start appearing in your member list suggestions for reflection macros in Visual Studio 2022 version 17.8. You can now quickly access all possible specifiers for respective macros without relying on memory or switching back and forth between Visual Studio and documentation.

A screenshot of Visual Studio's member list suggestion Unreal Engine Macro specifiers

Improved Blueprint Experience in Visual Studio

In the coming weeks, Unreal Engine developers will gradually gain access to this experimental feature in the Visual Studio 2022 version 17.9 Preview channels.

a screenshot of blueprint references showing as codelens hints in visual studio

Blueprints support in Visual Studio just got easier. You can now view Blueprint references and Asset Properties without installing the Visual Studio Integration Tool plugin. The update removes the requirement for building your game before gathering Blueprint information. You will notice a significant enhancement in the way Blueprint references are handled. Visual Studio will now display CodeLens hints with less machine resources and reduced latency. Next, we have added support for including usages of UFUNCTIONs outside of the class hierarchy directly in the CodeLens results. Lastly, we will cache the results from previous scans and only process new or modified assets since the last scan.

Improved IntelliSense for Unreal Engine Projects

Unreal Engine uses its own reflection mechanism to connect its C++ and Blueprints worlds. This is achieved through custom preprocessing of C++ sources with Unreal Header Tool (UHT) and injection through the regular C++ preprocessor. In Visual Studio 2022 version 17.9 Preview 1, we have improved the handling of Unreal Engine IntelliSense by ensuring consistency and accuracy. IntelliSense in Visual Studio will now refresh more readily for UHT generated files, reducing the likelihood of displaying unwarranted errors.

Unreal Engine Macro Indentation Rules

In Visual Studio 2022 version 17.7, we’ve introduced special indentation rules for reflection macros and slate declarative syntax. We’re always looking for ways to improve, and we’ve been thrilled to hear positive feedback from the community. We would love to hear your thoughts on any additional Unreal Engine macros that you think should be considered. Please share your thoughts in the comments below or on X @VisualC.

Core C++ Productivity Features

Thanks to the amazing and positive feedback from AAA game developers, we have created many core C++ productivity features that will benefit all C++ developers.

Build Insights Functions View

Build Insights is now integrated with Visual Studio 2022 and works with MSBuild and CMake projects. Backed by MSVC’s trace capture technology, you can now see additional information relating to function generation in Visual Studio 2022 version 17.8. The new Functions View will provide you with how long a function takes during compilation as well as the number of ForceInlines associated.

A screenshot showing the Build Menu in Visual Studio with Run Build Insights on Solution selected

Start your Build Insights .etl trace capture by going to the Build Menu.

A screen shot of build insights functions view

After compilation, Build Insights will create a diagnostic report that shows you function generation time and number of ForceInlines.

const and static Suggestions

New to Code Analysis in Visual Studio 2022 version 17.8, you will now see Visual Studio show suggestions to make member functions const and global functions static. You will increase your code’s consistency, readability, and security with the addition of these two features. For detailed information, please see Make Member Function const and Global Function static in Visual Studio.

Make Member Functions const

Visual Studio will identify cases where a member function can be made const. This can provide additional guarantees to the caller of the function and can also enable certain optimizations by the compiler. The linter suggestion will only be offered if the member function does not mutate the state of the object.

Make function const in multi file GIF

The feature will suggest a member function can be made const by displaying three dots below the function. A message will appear when you hover over the dots, informing you that the member function can be made const. You can then click on the light bulb to make the member function const. The changes will apply to all files that have the selected member function.

Make Member Function Const Setting

This feature is on-by-default. You can customize the severity of these suggestions by going to Tools > Options > Text Editor > C/C++ > Code Style > Linter.

Make Global Functions static

You will now see hints in Visual Studio when global functions can be marked as static. Static functions have linkage limited to one translation unit, which can help improve performance by allowing the compiler to perform certain optimizations. As a bonus, this will also prevent naming conflicts due to internal linkage. The feature works well with modern C++ projects and will not make suggestions for functions within anonymous namespaces. Static global functions are accessible within the translation unit where they are defined.

Image make function static

You will see a suggestion appear with a screwdriver icon for global functions without a forward declaration. This suggestion will indicate that you can make the function static. You can make the function static by clicking the screwdriver icon and selecting “Make this function static”.

Make global function static setting.

You can also customize this feature by changing the setting in Tools > Options > Text Editor > C/C++ > IntelliSense.

Size and Alignment Information

Viewing Size and Alignment in Quick Info

In Visual Studio 2022 version 17.8, you can easily see the size and alignment of any class, struct, union, base type, or enum in C++ by simply hovering over its name. No more scrolling or searching for declarations. Just hover and get the information you need in a glance. This feature will help you write more efficient and robust code in C++.

a screenshot of quick info on a Unreal Engine class showing size aend alignment information

This feature is on-by-default. To access the settings, go to Tools > Options > Text Editor > C/C++ > IntelliSense.

#include Directives

#include Cleanup

Thanks to your feedback, you can now use #include cleanup to remove unused headers, add direct headers, and help you maintain clean code. To maximize the use of #include cleanup, we recommend first using the direct include suggestions, then the unused include suggestions.

Gif showing remove unused includes.
Gif showing remove unused includes.

#include cleanup is off-by-default. You can enable it by navigating to Tools > Options > Text Editor > C/C++ > IntelliSense and selecting “Enable #include cleanup.” Once enabled, you have the flexibility to adjust the settings and configure different levels to meet your specific needs and preferences.

For detailed information on how to fully utilize the new #include clean up tool, please see Clean up C/C++ #includes in Visual Studio.

Sort #include

In Visual Studio 2022 version 17.8, we have made it easier for you to organize your #include directives in C++ according to your preferences.

A gif showing configuring sort includes then actually sorting the includes

You can sort them with a simple right-click on any #include statement and choose the “Sort #include directives” option. In addition, you can also sort them automatically with the Code Cleanup feature, which you can configure by adding “Sort #include directives (C++)” to the Included fixers section. Sorting your #include directives will help you manage your dependencies, avoid duplication, and improve your code quality.

You can configure include cleanup and sorting at Tools > Options > Text Editor > C/C++ > Code Cleanup. 

#include Diagnostic References

In Visual Studio 2022 version 17.9 Preview 1, you will be able to utilize #include diagnostic references to help you analyze how your #include directives are used in your C++ code. You will see the number and locations of references for each #include directive in your codebase.

Image include diagnostics r

Click on the reference count to see a list of references and double-click on any reference to go to its location. This feature can greatly help you manage your dependencies and avoid duplication.

Visual Studio Performance and Debugger Improvements

Improving Time to Colorization for Large C++ Projects

In Visual Studio version 17.8, our team has implemented significant enhancements to the performance of IntelliSense and colorization in C++ files for large projects. Specifically, we’ve improved the speed at which these features become available when opening a previously accessed (cached) file. To achieve this, we’ve restructured the loading of IntelliSense state into multiple phases, with a focus on prioritizing the most critical information. This includes colorization and highlighting selected references, which are now computed first. As a result of these optimizations, you will experience a faster and more efficient experience.

a graph showing time to intellisense bench marked on unreal engine 5.1. VS 17.8 =1.3s VS 17.7 =1.8s

Improved Debug Launch Speed for C++ Projects

In Visual Studio version 17.8, you will launch the debugger faster. We’ve substantially enhanced F5 performance for Windows applications by optimizing breakpoint setup. For example, this optimization delivers a remarkable 20% speed improvement for Unreal Editor projects. These improvements optimize file presence checks within modules, benefiting debugging C++ code with numerous breakpoints and files involved in the build process. Furthermore, we’ve streamlined the Windows PDB loading process, reducing the time required to load a PDB once it’s located.

graph showing faster debugger launch speed 24 secs in 17.7 and 19 secs in 17.8

Instrumentation Tool: New “Start with collection paused” Option

In Visual Studio 2022 version 17.9 Preview 1, the Instrumentation Tool now includes a “Start with collection paused” option for profiling C++ applications. With this feature, you can start your game under the profiler’s control without immediately collecting data. This allows you to get into the game before data collection starts. Additionally, you can resume data collection later when needed by hitting the record button.

A screenshot of the Visual Studio profiler with a new option "Start with collection paused"

Feedback Wanted!

With the latest game developer productivity updates in Visual Studio 2022, we aim to empower game developers and enhance their productivity through innovative and powerful tools. This release is another step towards our vision of a streamlined game development process. Your feedback has been instrumental in shaping our development path. We strongly encourage you to continue to share your thoughts and ideas with us by reaching out through Developer Community, surveys, X (@VisualC), or email at visualcpp@microsoft.com. Thank you for your continued support. Together, we can drive game development to new heights with Visual Studio 2022.

Author

David Li
Game Dev Product Manager

I am a video game developer focused PM on the Visual C++ Team. Talk to me about video games!

2 comments

Discussion is closed. Login to edit/delete existing comments.

  • yuan mnm

    the speed improvement for large project is so great

  • Dan Goes

    These are GREAT! Thank you everyone responsible for these improvements, and especially the Sea of Thieves team at Rare pushing the state of art on testing with Unreal & Visual Studio.