How to use "save_scene_as ()" method in EditorInterface class?

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


Can i save current scene to file during the game using save_scene_as () method?
If so, how i can get access to EditorInterface class from the code?

EditorInterface.save_scene_as (filepath) - not works


:bust_in_silhouette: Reply From: volzhs

EditorInterface is for the editor not running game.
if you want to save a scene or specific node on runtime,
use PackedScene and ResourceSaver
you can see example code in PackedScene on editor help.

Here is an example code from it.

var scene =
var result = scene.pack(child)
if result == OK:"res://path/name.scn", scene) // or user://...

Thank you for help.

damncoder | 2018-05-15 07:34