Getting world in a editor plugin


I have an UObject which is not in the world (just created with NewObject), and I need to create an object in the world from it.
I have tried GEngine->GetWorld() and GEditor->GetWorld(), but both of them returned wrong values.
I finally did it, but it’s really, really awful:

 TArray<FEdMode *> arr;

Is there a better way to do it?

Thanks, Tavon.

I’m using this in my plugins, is this what you are after?


Yuup that’s it, thanks a lot !

Thanks! Anyone know how to get PIE World in Editor Plugin? Method above will always return editor world not PIE World.

1 Like

thanks! this was really useful

You saved me \o/

This is not working anymore. Its causing crash :frowning:

Not working anymore. Right one is:

		if(GEditor && GEditor->PlayWorld)
			return GEditor->PlayWorld;
1 Like

when I get the editorWorld in plugin, why it always return nullptr in UE4.21.2 ? only return true when I press the Play Button

void FTerrainDrawerEdModeToolkit::Init(const TSharedPtr<IToolkitHost>& InitToolkitHost)
	struct Locals
		static bool IsWidgetEnabled()
                     UWorld* world = GEditor->EditorWorld;
			if (world == nullptr)
				UE_LOG(LogTemp, Log, TEXT("world not exist!"));
				return false;
				UE_LOG(LogTemp, Log, TEXT("world exist!"));
				return true;


I have tested the UWorld* world = GEditor->EditorWorld; in a IModuleInterface, and it does not work (pointer is null)

Thanks, for a plugin that inherits from IModuleInterface, this is the right way to do!

Is there any way of changing current level in plugin?