Selecting an actor in UE4 edtior automatically.

Hello I have a main actor which is spawning many child actors through the OnCOnstruction() function in the editor.

I want something so that when a child actor is selected in the ue4 editor, the selection gets canceled and the main actor gets selected.

Anyway how to that? Or any files can i refer for editor selection of an actor?

Something like this should help:


#if WITH_EDITOR
     // Clear all selection
    GEditor->SelectNone( false, true );

     // Select your Actor
    GEditor->SelectActor( YourMainActor, true, true );
#endif

I am getting GEditor is undefined.

Go to your projects source folder. There you should see YourProjectName.Build.cs. Open that and…

1: Add UnrealEd to PrivateDependencyModuleNames (eg: PrivateDependencyModuleNames.AddRange(new string] { “UnrealEd” }); )

2: Then in your source file (where you are accessing GEditor) add ***#include “UnrealEd.h”

***Done. :slight_smile:

1 Like

I’m trying to do it from a plugin and it crashes slate everytime. I can’t find the source of the problem.