Error C3861: 'GetWorld': identifier not found

Hey Guys, I am using the below code snippet in a Plugin Module and I am getting this error. The same code snippet if I use in an Actor class there are no errors. Can someone please tell me why is that?

Thank you

UWorld* const World = GetWorld();
FString MapName = GetWorld()->GetMapName();
MapName.RemoveFromStart(GetWorld()->StreamingLevelsPrefix);
UE_LOG(LogTemp, Warning, TEXT("%s"), *MapName);

error C3861: ‘GetWorld’: identifier not found

For the plugin, you can use this: GEditor->GetEditorWorldContext().World()

Other option is – if it’s inside some public method – you can receive a world context object and call the GetWorld() from it.

Hey, thank you so much, it worked :slight_smile: