Hello, everyone. I have a problem that somehow I need to build the Import function in the assembled game. In the editor everything works well and correctly, but if you build the project, you need to use the #if WITH_EDITOR macro. But this macro does not add the function to the built game, I tried to change the value in .target.cs, but although it says that the macro value has changed, but the built game will not change. I also tried to change the value inside the Unreal Engine, but then unreal stops compiling because of some libraries that work only when WITH_EDITOR = O. Is there any way to solve the problem? Thank you for your help!
Знімок екрана 2025-03-09 143448|690x219
#if WITH_EDITOR is a macro that checks if you are in the editor. It is not to enforce that editor functions are included into the packed game. It’s the other way around.
Elements marked with
#if WITH_EDITOR
#endif
will be stripped out of the shipped build.
You cannot add editor only functionality to your shipped game.
Is it possible to add Landscape->Import to my built game? When I build Landscape->Import without WITH_EDITOR, it gives an error C2039 that it does not see such a function as Import when building the game
You are misunderstanding what with editor means
You cannot use any with editor functions in you shipped game, ever.
These are functions that require parts of the editor to function. You are not allowed to distribute the editor code with your game.
Any code that is marked as with editor is cut out of your game / deleted out of the code when it is compiled.
The terrain editing tools are unfortunately tied directly to the editor. Your ability to edit at runtime are near zero without building your own tools.
You would maybe try accessing the height map and manipulate the internal data but it’s tough as it cannot be exposed to blueprint so you would need to make all of the tooling in c++. There is too high precession data (64 bit) that doesn’t work well with exposed functions.
Okay, I understand where my mistake was, thanks for your help
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.