I have a custom details panel that I’ve added to an actor with a button. On the press of that button, I’m attempting to spawn other actors into the level. They spawn just fine, but the problem is they do not run their construction script until I either manually move them or modify a value on them in the editor.
I’ve tried spawning them with GEditor->AddActor(), GetWorld()->SpawnActor(), GetWorld->SpawnDeferredActor() and then calling FinishSpawning(), nothing will make it fire it’s constructor when it’s placed.
I’ve also tried programatically modifying a property or moving the actor immediately after spawning it. The values change on the blueprint, but it still doesn’t construct.
I’ve tried adding a BlueprintImplementableEvent and implementing it in the blueprint and calling it from C++, but even though there are no errors it doesn’t seem to get called at all.
I’ve completely run out of ideas here, so any help would be appreciated.
The problem is this is an editor tool so it needs to happen in editor time, not during runtime. I’m using the following code to add the actor to the level in the editor:
The actor gets placed just fine, but the constructor never fires in the editor. I’d expect it to fire the same as if I had manually drug an actor from the content browser into the viewport.
Edit:
Just to add a bit more after trying some things. The C++ constructor does fire, but the blueprint’s does not. I tried calling a blueprint implemented function from the C++ constructor as a workaround, but it doesn’t seem to get there.
I finally figured out how to get the results I wanted. When using GEditor->AddActor() to place an actor, it does run the construction scripts in the editor, not sure why I thought it wasn’t. But I also needed to modify some properties on the actor and then re-run the construction script, and finally found the function call I needed to do that: