Is there a tool to convert Blueprint data structures to C++ automatically?

I am working through the course “Converting Blueprint to C++”. The author suggests to implement structs in C++ from the get go (rather then implementing them in Blueprint and moving to code later).

I feel, the same might be true for most of my data (the UPROPERTY stuff). Because this way, I can prototype using Blueprint w/o having a lot of pain alter when migrating performance-critical functions.

Also, conversion of data (i.e. structs, simple types) is mostly really straightforward and follows a couple of rules. So should I follow my intuition and implement data in C++ (having it available in Blueprint, too, for free)? Are the tools to automize the task, if I do it later? Are there changes in UE5?

1 Like

Use blueprint nativization in the project settings.

Check this link: Nativizing Blueprints | Unreal Engine Documentation

This might take more storage for the packaged game.

1 Like

It is not difficult to convert bp structures etc to c++ ones. Just convert 'em manually - it takes no time at all…

3 Likes

It does feel like a lot of work when thinking about it, but it’s no more than a couple of hours, even for a big project. One of those things where just as little bit of persistence will deliver just fine!

Re-type in the properties and types of each blueprint class. Re-parent the blueprint to inherit from the C++ class. Repeat.

In general, it’s a good idea to build most of your base classes in C++, with properties and event dispatchers. Perhaps also blueprint overridable virtual functions for the most crucial pieces. Then parent your blueprint classes to those C++ classes, and use them in the game. This makes overriding/changing/trying things easy, while the C++ is already there once you know you need a particular feature/behavior.

2 Likes

Has anybody ever tried using the code you get from exporting the asset or copying the nodes (like blueprintUE) to convert blueprints to C++? From a glance, it looks like it gets all the data needed to recreate them in C++.

2 Likes

I resort to working mostly in C++ now. I will still use Blueprint child classes to benefit from the graphical interface of the unreal engine wherever possible. E.g. I won’t hardcode links to assets in C++.

This way, I probably won’t ever need to convert Blueprints to C++, thanks for the hint though.

Also, I would love to do certain stuff within Unreals visual scripting. I am a programmer and I feel at home with C++, but connecting events to event handlers and so on is something I’d rather do in a visual style. My plan was to implement functions in C++, make them Blueprint callable and then put everything together high-level in the Blueprint EventGraph.

However, I still have to see whether or not that approach is practically feasable.

As an example: I could, right now, copy the code within my overloaded Tick method into several class methods with expressive names, all of them BlueprintCallable. And then, instead of calling them in C++, I would put them in the Blueprint Tick event. I argue that would help a lot with readability: The Blueprint would explain on a high level what happens each Tick.

And even more, I could use the visual coding to disconnect stuff instead of turning code lines into comments temprorarily, to deactivate behavior and so on.

But I wonder if it’s all worth it, given that I basically introduce an extra step.

I might as well stick to C++.

2 Likes