[C++ Tool] Select Actor in Editor using C++

Hello everyone!

I’m creating a tool in C++ and I want my actor to select another actor in the editor/world. Precisely, on the Actor’s EditorKeyPressed event, I check if the enter key is pressed, actor is selected, and if the actor has a parent actor. If all conditions are met, I would then select the parent actor.

Thanks!

GEditor->SelectActor(…)

I think all you need is input actor. Lot of editor operations can be done from UEditorEngine, which global pointer to is GEditor.

Remember that if you put this code gameplay module place editor code inside #if WITH_EDITOR #endif borders or else your project won’t cook.

1 Like

Thanks for the answer! (:slight_smile:)

hmmm…got this error when I tried. any ideas?

1> [2/2] Link UE4Editor-Prizefighter-Win64-Debug.dll
1> Creating library C:\UnrealEngine\Prizefighter\Intermediate/Build/Win64\UE4Editor\Debug\UE4Editor-Prizefighter-Win64-Debug.lib and object C:\UnrealEngine\Prizefighter\Intermediate/Build/Win64\UE4Editor\Debug\UE4Editor-Prizefighter-Win64-Debug.exp
1>Module.Prizefighter.cpp.obj : error LNK2001: unresolved external symbol “__declspec(dllimport) class UEditorEngine * GEditor” (_imp?GEditor@@3PEAVUEditorEngine@@EA)
1>C:\UnrealEngine\Prizefighter\Binaries\Win64\UE4Editor-Prizefighter-Win64-Debug.dll : fatal error LNK1120: 1 unresolved externals

nm…found my answer here: