Check if Blueprint is being run within the editor (i.e if WITH_EDITOR in C++)

I’m looking for the Blueprint equivalent of #if WITH_EDITOR which is used in UE C++ to run perform certain actions only if the game is running within the context of the editor.

The main intention is to add useful debugging information in exceptional scenarios. Eg: Cast To MyActor fails and I want to print a simple message to the screen so I know that. I realize I can use the output log for this but I find it too verbose for this purpose. So does any such node exist to determine if game context is within the editor?

Not sure if the fact that blueprints being converted to a different form while cooking the game prevents such a check from being feasible.

2 Likes

Bump. I’m having the same problem, anyone have any solution?

2 Likes

I can’t believe that there’s no answer for this question!
The best way I know is GetPlatformName node, but I don’t think it’s a good way, since it only returns Windows for PIE.
So is there really no BP equivalent for WITH_EDITOR?!

2 Likes

Bump…Bump…

Yes im sure ive seen a bp node already that does this i’m not at my computer right now but I’ll look later and post it if I find it

Or you could do it yourself simple make a c++ function like this

//! Allow the blueprint to determine whether we are running with the editor or not

UFUNCTION( BlueprintPure, Category = Whatever )
bool IsWithEditor() const
{
#if WITH_EDITOR
return true;
#else
return false;
#endif
}

4 Likes

Yes. I think I found a method. Try Is Shipping Build node. Make a branch and if Is Shipping Build is equal to true, then do whatever you want and if it is false, then do nothing. I tried it in 4.13 and it works.

Add a custom option, such as “-editor” inside the server game options line, found in Edit->EditorPreferences->Play(LevelEditor)->MultiplayerOptions->ServerGameOptions.

Then make a macro or a global function in BP to GetGameOptions->DoesOptionExist("-editor").

Rama’s free Victory Plugin has a node to identify whether game logic is running in Editor,PIE,or Game World!
(39) Rama's Extra Blueprint Nodes for You as a Plugin, No C++ Required! - Blueprint Visual Scripting - Unreal Engine Forums!

Also the free Low Entry Standard Library plugin has a platform node (not exactly what you want, but it also has other useful stuff )

2 Likes

Since this is where google led me and it has NOT been updated, there is a ‘With Editor’ node now… You can just use that (its in the same place as the Is Shipping, Is Debug, Etc nodes)

Where are these With Editor and Is Shipping nodes that you speak of? I’ve tried adding using them in Blueprint in 4.24 but these nodes don’t exist. I’ve unticked Context Sensitive too, but they still don’t show up?

A bit late but in case people are still looking for it (like me XD )

There is the node “Print String”, which spawn the message you want in the editor during play.
Not sure if it’s what you are looking for as I don’t know C++, but here you go
Print-string.PNG

Same issue here. Were these removed?

Or did the name change? This thread is literally the only result if I search for it.

1 Like

As of 4.25, this is the correct answer:

Capture.JPG

18 Likes

Thanks, this is exactly what I was looking for!

This is NOT correct answer, as this have next code inside:

	static bool IsPackagedForDistribution()
	{
#if UE_BUILD_SHIPPING
		return true;
#else
		return false;
#endif
	}

Correct answer is to create Blueprint Library using C++ and use solution from @EniGmaa .

3 Likes

The node “Is Packaged For Distribution” works for me as well!

Some of us using Unreal Engine aren’t game developers and don’t use any C++

check the free plugin LE Extended Standard Library in Code Plugins - UE Marketplace
That has those nodes without the need to do anything more than install it and it’s free

3 Likes

If that is your plugin, you should make it 100% clear on the marketplace page if the plugin requires the project to support C++ or not. Right now, to me it seems as if it does, which disqualifies it for us.

The solution I posted works for those who do not wish to have C++ at all.

1 Like

No, I used that plugin before, no need for C++.