How can I make UFUNCTION(exec) work inside #if !UE_BUILD_SHIPPING?
I would like to have a debug function as follows:
However, it seems that the Exec does not persist when written in this way. The function and variable are created and may be called upon at runtime. If I comment out the preprocesser lines, the function does properly show up in the console.
I am doing this to create very simple debug functionality that can be run in the editor or in a normal development runtime build that is not "SHIP"
Any tips or suggestions to solve this would be much appreciated!
We had the same problem on our project. I found that using the existing UCheatManager system makes adding debug functions rather easy.
First, extend UCheatManager in your own class:
Then, implement it in the constructor of your player controller class:
The APlayerController class has the code for enabling and disabling cheats (debug functions) based on build type and gamemode settings.
Follow this question
Once you sign in you will be able to subscribe for any updates here