Tavon
(Tavon)
July 11, 2015, 1:21am
1
Hi,
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;
GLevelEditorModeTools().GetActiveModes(arr);
arr[0]->GetWorld()
Is there a better way to do it?
Thanks, Tavon.
2 Likes
Goomii
(Goomii)
July 11, 2015, 7:06am
2
I’m using this in my plugins, is this what you are after?
GEditor->GetEditorWorldContext().World()
6 Likes
Tavon
(Tavon)
July 11, 2015, 9:18am
3
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
This is not working anymore. Its causing crash
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;
}
else
{
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?