Which Macro to tell the difference between PIE and WindowNoEditor?

I run my code in two environment, one is PIE, the other one is packaged exe on windowsnoeditor platform. Now since I’ve used pak to load content into my game, I need to find a macro to tell me which environment I’m running with. So that I can load cooked pak when running windowsnoeditor, and uncooked pak when running the other.

I’ve tried WITH_EDITOR but failed, seem like it’s always defined on both windowsnoeditor and xxx editor configuration.

Assume that you have WorldObject is UWorld* to current game world.

WorldObject->WorldType == EWorldType::PIE
WorldObject->WorldType == EWorldType::Editor

Here is API References

WorldType API Reference

EWorldType::Type

WITH_EDITOR should be defined as 0 in packaged builds.
Anyway you can made your own macro in *.Buld.cs file, which always will be 0 outside the editor build

PublicDefinitions.Add(String.Format("CUSTOM_WITH_EDITOR={0}", Target.Type == TargetType.Editor ? 1 : 0));
1 Like