How do I Spawn an Actor from a custom Editor Window?

I am attempting to Spawn an actor, but all the previous methods use GetWorld()->SpawnActor. However, from a custom SWidget inheriting from SCompoundWidget, I do not have direct access to the world. If anyone knows the best way to spawn an Actor from a custom widget, that would be awesome!

What is your Custom Editor Window? Is it a custom UE4 editor window? Or an in-game-editor window? Not really clear.

Since your talking about widgets, I will assume it’s the later. In this case, you want the widget to fire off an event in the level blueprint. For this, you will need an event dispatcher.

In the widget you add an event dispatcher, and in the level blueprint you bind an event to that dispatcher.

Check out this vid:

It is not in-game. It is a UE4 editor window that I wish to be able to spawn an actor upon a button press into the non-running simulation. Unfortunately the video doesn’t really apply in that case, but I appreciate it nonetheless.

Ok. That’s more clear, It also seems like your focus is on C++ dev.

From the editor, you can drag-and-drop actors into the editor scene. But there is no button to do so.

And as far as a custom editor window, I’m not aware of anyone focused on that sort of development. AFAIK, Epic has not released the editor source code.

Also, when you say ‘non-running simulation’, you mean the scene in the editor?

Exactly! Basically I want that same drag and drop functionality, but on a button with a specific actor. I’ve been hunting through the source code to find out how that is done in c++ code within the engine.

What you want is a feature for the editor.

The game engine and the editor do not share the same code. We have access to the engine code and use it make games. We do not have access to the editor code which provides us with the windows and blueprints.

So then Spawning something into the scene cannot be built into an editor plugin? It seems like one can grab all of the actors in a scene and modify them, as shown in the extending the editor video here C++ Extending the Editor | Live Training | Unreal Engine - YouTube, and thanks for all of the insight!

There you go. I stand corrected.

So, yes, you can. The button is will need to reference an actor. That might be very complicated. I would start small, like a button that just adds a cube.