Instantiating a Scene and Adding as a Child in the Editor?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By 398utubzyt

I’m currently making a C# plugin which acts as an “editor-loader” for user-created editors of a specific type provided by said plugin. My current method of going about loading the actual editor resources is by having the user drag a scene into an external window created by the plugin and load it from there.

There seems to be an issue with instantiating a scene inside the Godot editor itself via:

_editorNode = ResourceLoader.Load<PackedScene>(path).Instantiate();
_editor.AddChild(_editorNode);
_EditorNodeReady(); // Does all the initialization work for the editor

Running this chunk results in an editor crash (specifically, _editor.AddChild(_editorNode);), even though it appears to work fine when ran outside of the editor. I’ve spent a couple days looking through documentation, forums, and even github issues with nothing coming up. Is there a workaround for this issue?