How can I tell if I'm in standalone or new editor window

Is it possible to tell if I’m in a new editor window or stand alone game in C++?

What I was asking was how can I tell how I’ve launched the game in code so that I can have separate logic for new editor window and standalone.

You can do that using the world type :

GetWorld()->WorldType

World type are those:

namespace EWorldType
{
	enum Type
	{
		None,		// An untyped world, in most cases this will be the vestigial worlds of streamed in sub-levels
		Game,		// The game world
		Editor,		// A world being edited in the editor
		PIE,		// A Play In Editor world
		Preview,	// A preview world for an editor tool
		Inactive	// An editor world that was loaded but not currently being edited in the level editor
	};
}

Basically, a PIE world is a world where you play but in the editor. A Game world is when you are in standalone, or a cooked game.

2 Likes

To my knowledge, it is not possible to do this as you’re still technically in the editor when launching a stand-alone game. I apologize for the lack of information. Hopefully if it is possible, someone else could provide the answer.

Have a nice day.

Hi THREEONEZERO,

Was this answer helpful? It’s been a while since we’ve heard from you so I will be closing this issue as resolved. If you do still require assistance, please feel free to comment and the issue will reopen.

Thank you

GEngine->GetNetMode(GWorld) is probably a better way of handling whether you are in standalone mode or not and you’ll have to combine it with the other answer to know if you are in the editor or not. See the examples below that will also provide you a node you can easily use in blueprints:

.h file:

	/** Returns true if this game is currently running in standalone mode. */
	UFUNCTION(BlueprintPure, Category = "Engine")
	static bool IsStandalone();

	/** Return the world type as a string (Client, ListenServer, DedicatedServer, Standalone, or nullptr) */
	UFUNCTION(BlueprintPure, Category = "Engine")
	static FString GetWorldType();

.cpp file:

bool UMyBlueprintLibrary::IsStandalone()
{
	if (GEngine != nullptr && GWorld != nullptr)
	{
		return GEngine->GetNetMode(GWorld) == NM_Standalone;
	}
	return false;
}

FString UMyBlueprintLibrary::GetWorldType()
{
	if (GEngine != nullptr && GWorld != nullptr)
	{
		return (GEngine->GetNetMode(GWorld) == NM_Client) ? TEXT("Client")
			: (GEngine->GetNetMode(GWorld) == NM_ListenServer) ? TEXT("ListenServer")
			: (GEngine->GetNetMode(GWorld) == NM_DedicatedServer) ? TEXT("DedicatedServer")
			: TEXT("Standalone");
	}
	return TEXT("nullptr");
}
1 Like

is there a way I can print out the WorldType?

Not natively, but you could always just check the value and print out a string based off which one it is, matching what the value was.

Is there any solution in BP to check if started as stand alone or in PIE?

Sorry, but GEngine->GetNetMode(GWorld) is not telling you if it is a “stand alone” started game. It simply says if it is a network started game. A launcher stand alone game, played in network, this will return as “false” stand alone game. I think the question is not about multiplayer game or sigleplayer game, the question is about “ue4 Editor started game” or “stand alone started” game.

How can i differentiate between Editor Play and PIE new window play(not in seperate process) … help