Hide code when cooking?
Quite new to Unreal and this week I worked on creating a class that represent a "road" for a race mini-game. The way I went about doing it is using SplineComponent and SplineMeshComponent. Also, in this class I override the OnConstruction function to do some stuff in editor.
It does a lot of stuff and, for example, it will trace the World in search of the ground so that the spline is always correctly sitting on it. It works fine in the editor and in standalone. The whole OnConstruction script is done in a #WITH_EDITOR block, since I want this stuff happening when the editor is builded in. So I compile my "Dev" configuration, it works, and when I compile in "Dev Editor" it also works correctly.
My problem arise when cooking the data. It will try to load a module which should not exist (the LevelEditor) from a function call within the OnConstruction function, and this make the cooking process fail.
Is there a way (like a #IS_COOKING define, for example) to make sure the editor stuff is not running while the editor is cooking?
Or maybe I'm not working correctly, is there an other way to do this? Have an object have Editor functionnality in the editor but have those stripped out in the final game?
For reference, I had to do this on my module rules to make this work correctly when compiling in Dev and Dev Editor configs :
asked Dec 05 '14 at 07:40 PM in C++ Programming
GIsCookerLoadingPackage might be what you're looking for. I've not had cause to use this myself yet though.
Another option is to have the spline components align themselves to the terrain from an editor only function such as PostEditChangeProperty rather than in the construction scripts. This would help separate your logic.
answered Jan 01 '19 at 08:12 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here