Enable console in shipping build

Hello, how can I enable the game console in a shipping build?

Hey Scienziatogm,

as far as I know this is not possible.
The console and also console commands are stripped out in the shipping configuration because they are made to be used for debugging and not for a shipped game.

Is there a way (maybe with custom code) to enable it?

You can make your own one with UMGs

Yes. I know. But is there a way to enable the classic console?

Not without modifying the source code I think.
You would need to find all the systems that the console uses and that are stripped out when in shipping build config and prevent them from being stripped. This could be a lot of work and would maybe end in a shipping build that is almost a development build which would make no sense.

Long story short, there is no way that I know to achieve this

That is absolutely unrecommended.

As I said, the best thing would be to use UMGs… it’s a lot easier for this purpose.

daje scienziĂ  :wink:

Some of us want console commands in our game. think Witcher, Fallout, sim city, age of empires etc.

I will try, I don’t think that console was fully stripped out. I think that there are 2-3 ifdefs.
Although, for those who doesn’t know: binary distributions are not allowed and source distributions take a long time to build (for me: 2h57m with i5-8400 and IncrediBuild acceleration). And if you have never worked with C++ (only Blueprints), this is going to be not very easy.
So, building your UMG console is the easiest way. Another way is Cheat Engine with pre-built shipping EXEs: https://web.archive.org/web/20170105000149/http://deviatted.com/batman-arkham-city-enable-console-rcheatmanager-commands/

Don’t, just make a custom one with UMGs, but make sure you check every single command that is entered - there is a reason why the console is stripped out of shipping builds. If it was not players could very easily use console commands to give themselves wall hacks, kill other players, god mode, etc…
If you want to include a console, make your own one, and have an array of allowed commands. Make sure each command entered is in this array before executing it.

#ifndef ALLOW_CONSOLE_IN_SHIPPING
#define ALLOW_CONSOLE_IN_SHIPPING 0
#endif

in build.h, seems to be a parameter built in. Have not tested it though. You do need to edit that bit of source.

Actually during las MegaJam trying to do that as gameplay element i find out console is still there, you just need to initiate it manually using this code:

#if UE_BUILD_SHIPPING
GetWorld()->GetGameViewport()->ViewportConsole = NewObject<UConsole>(GetWorld()->GetGameViewport());
// register console to get all log messages
GLog->AddOutputDevice(GetWorld()->GetGameViewport()->ViewportConsole);
#endif

This won’t prevent lot of console commands to be locked up in shipping build and log system to not function. But there also neat way to capture user inputted commands by overriding this function allowing to create custom console:

note since that’s only set to 0 if it wasn’t defined before you can try to (i didn’t test that, might only apply to that module) just define it using:

PublicDefinitions.Add("ALLOW_CONSOLE_IN_SHIPPING=1");

in your project’s .build.cs (then obviously rebuild the whole engine for that project skipping the “intermediates”, which is gonna take ages).

there are also the .target.cs which might help there:

public override void SetupGlobalEnvironment(TargetInfo Target, ref LinkEnvironmentConfiguration OutLinkEnvironmentConfiguration, ref CPPEnvironmentConfiguration OutCPPEnvironmentConfiguration ) {
 OutCPPEnvironmentConfiguration.Definitions.Add("ALLOW_CONSOLE_IN_SHIPPING=1");
}

if it is module-only and doesn’t actually influence the engine code, you might instead try to just add another “build platform” in your engine build config that just overrides that.

By the way, the consolle itself does work on shipping builds, for example i can run commands triggered by blueprint events with the execute command node, but you cannot pull the text editor box to type commands

Posted my solution of restoring console in the shipping build in another thread: How do i open the console in a shipped game ? - #13 by Kulagin

1 Like