In 4.12 there is new experimental feature: Blueprint Nativization.(Some of you already found it in 4.11, but it wasn’t ready to be announced).
What does the feature do?
Generates c++ code from Blueprints
Compiles the project with the generated code (only non-editor builds)
Cooks the project with BlueprintGeneratedClasses replaced by newly generated native classes
The main goal of the feature is to reduce the VM overhead in runtime.
The aim of the feature (so far) is not to generate readable/friendly/reusable code.
This is an experimental beta feature. All UE4 sample games and some medium size demos were successfully nativized, but we’re still working on using the feature with the biggest projects (Paragon).
If you use UAT scripts, add “-nativizeAssets” switch in BuildCookRun command line.
What assets are converted:
Blueprints (classes, function libraries, interfaces),
User Defined Structures,
User Defined Enums
What assets are not converted:
Any manually excluded Blueprints
If your project contains C++ code, make sure that all headers are properly included in your source code.
There are some rules/restrictions that help make cooperation between manually written code and the nativized code more reliable and efficient.
Do not use:
private/protected properties with BP-Visible or Editable tags
private/protected functions callable from BP
bit-fields properties with BP-Visible or Editable tags
private bit-fields properties
properties of types: UBlueprintGeneratedClass, UUserDefinedStruct, UUserDefinedEnum (or any type based on them)
How to exclude blueprints from nativization?
In DefaultEditor.ini in [BlueprintNativizationSettings] sections there are:
The feature should work both with VS2013 and VS2015. VS2015 is strongly recommended, especially for bigger projects. A big problem is the size of generated library. VS 2015 handles it much better. If there is a strange compiler/linker error like LNK1000, LNK1248, then try to reduce the amount of nativized Blueprints.
The nativized code is stored in *<project>\Intermediate<platform>\NativizedAssets\Source\NativizedAssets\ *(the path was changed since 4.11)
The BlueprintCompilerCppBackend module converts Blueprint syntax tree into C++. *Engine\Source\Developer\BlueprintCompilerCppBackend*
The BlueprintNativeCodeGen module does a lot of magic while cooking and packaging. *Engine\Source\Developer\BlueprintNativeCodeGen*
Assets are nativized if (and only if) they are cooked. When the cooker has no assets/maps specified (to be cooked) it cooks everything from content directory. So if you see some unused blueprints nativized, try to fill “Project Settings > Packaging > List of maps to include in a packaged build” (or MapsToCook in DefaultGame.ini).
How to debug the converted code?
If you nativize a BP-only project, then (after nativization) run GenerateProjectFiles.bat. It will add a new project to UE4 VS solution. Do not use this project to compile anything in VS. Also do not use this project to run Editor.
To build a debug .exe file run the following lines. They can be found in log output, when nativized build is packaged (but instead of Debug there is Development switch). It’s better to copy them, so all switches are proper for your environment.
Great work Im really looking forward to using this and Im expecting it to make a real difference in some of the more computationally expensive parts of my BPs. Basically I can write CPP but it was just too tedious to try and manage both CPP and BP end of thing especially for smaller projects where CPP is kinda overkill. Id really like to see a light weight text scripting system like UScript be built ontop of Blueprint and Slate, so instead of displaying nodes it displays it as text, this way we can get some speed improvement if we need to say type a long expression we can flick back and forward between script/node view.
I do think the RMB shortcut menu could be sped up by making enter (or another key) a way to bring up the menu as well as the RMB, so you can more continually type without baby sitting the mouse for the next node creation.
Anyway I really like where you guys are going with all of these Blueprint improvements so thank you and totally looking forward to future releases
Can you please explain, what does it give in practice?
I created two mobile TopDown projects, then deployed them - first without this feature, second with.
Tested on an Android device(Samsung Galaxy Ace Style). And I got 29-31 FPS and 16-18ms on both.
Converting blueprint to C++ reduces the amount of overhead you get from executing blueprint code. While C++ is ~10x faster, if you are not doing a lot of work in a very short amount of time, such as in a single frame, you may not see a difference. Blueprint is still relatively fast for most uses.
Is this Windows only ATM? I’m trying to do this on a mac and packaging is throwing tons of errors and failing. I’m running OS X 10.11.5, XCode 7.3.1, and of course UE4 4.12.0. Just curious if anyone’s tried this on a mac yet… Cheers,
You probably won’t get the same performance out of a “nativized” blueprint that you would get out of a similarly hand-coded C++ game file.
The reason is that Blueprint derived C++ must make sure to adhere to the Blueprint rules of execution, flow, etc, so it will likely generate more and more cumbersome code than a C++ programmer would write by hand.
That being said – from what I can tell, it should speed up blueprints, and in the future, I hope we can choose to “convert blueprint to C++” and then start hand-editing the generated code to make it great again.