How to open console from Execute Console Command

How to open console from Execute Console Command?

image

Hey there @ganbaa_elmer! So Execute console command node actually just sends whatever command you put in that string there, it won’t show the console itself.

If you’d like to show the console itself via a key, you’ll have to go to Edit->Project Settings->Input and look under the Console tab. You’ll see there that you can add additional keys that will open up the console in game.

Let me know if you have any questions!

7 Likes

is it working on IOS mobile game with shipping configuration?
and how to show console itself from Execute Console Command

I have only tested it with with windows 10 standalone build, so I cannot say for sure, but mobile (both android and iOS) can actually bring up the console with the 4 finger tap if enabled in the same settings area.

As for your second question, are you asking how to show the console in blueprints? Since there’s no console command to show the console because you’d have to already have the console up to call it in regular situations. To use execute console command node and see what it’s outputting, you’ll have to open the console via it’s bind or the 4 tap or make a widget that shows the input.

There’s no standard way to force the console back up outside of the editor functions from before.

If you’re asking more so how you could make a custom console separate from the one you bring up via the 4 tap or ~ regularly, then I can find you some tutorials if you’d like?

1 Like

yes thank you please help me

As this functionality is not exposed to BPs or console commands you can do it with some C++. There are other tutorials online on how to set up Visual Studio with Unreal Engine, this assumes you’ve already done that.

Click Tools → New C++ Class:
image

Click the “All Classes” button and filter by “BlueprintFunctionLibrary”, then select BlueprintFunctionLibrary as the parent class and click Next.

Then name your class something like BlueprintConsole and click Create Class.

In the header file (BlueprintConsole.h), put this code:

#pragma once

#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "BlueprintConsole.generated.h"

UCLASS()
class UBlueprintConsole : public UBlueprintFunctionLibrary
{
	GENERATED_BODY()

public:
	UFUNCTION(BlueprintCallable, meta=(WorldContext = "WorldContextObject"))
	static void OpenConsole(UObject* WorldContextObject);

	UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"))
	static void OpenConsoleFull(UObject* WorldContextObject);

	UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"))
	static void CloseConsole(UObject* WorldContextObject);
};

In the C++ file (BlueprintConsole.cpp), put this code:

#include "BlueprintConsole.h"
#include "Engine/Console.h"

static const FName NAME_Typing = FName(TEXT("Typing"));
static const FName NAME_Open = FName(TEXT("Open"));

void SetConsoleState(UObject* WorldContextObject, FName NewConsoleState)
{
	if (!IsValid(WorldContextObject)
		|| !IsValid(WorldContextObject->GetWorld())
		|| !IsValid(WorldContextObject->GetWorld()->GetGameViewport()))
	{
		return;
	}

	// Console might be null, like in shipping builds or on consoles.
	UConsole* ViewportConsole = WorldContextObject->GetWorld()->GetGameViewport()->ViewportConsole;
	if (IsValid(ViewportConsole))
	{
		ViewportConsole->FakeGotoState(NewConsoleState);
	}
}

void UBlueprintConsole::OpenConsole(UObject* WorldContextObject)
{
	SetConsoleState(WorldContextObject, NAME_Typing);
}

void UBlueprintConsole::OpenConsoleFull(UObject* WorldContextObject)
{
	SetConsoleState(WorldContextObject, NAME_Open);
}

void UBlueprintConsole::CloseConsole(UObject* WorldContextObject)
{
	SetConsoleState(WorldContextObject, NAME_None);
}

Save these files and compile them, either from Visual Studio, or from Live Coding (ctrl+alt+F11) while the editor is running.

Now you can call these new function directly from blueprints. Take note that the console only works in Development builds, it gets compiled out in Shipping builds.
image

5 Likes