0 votes


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

EditorInterface.save_scene_as (filepath) - not works


asked May 15 in Engine by damncoder (55 points)

1 Answer

0 votes

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 = PackedScene.new()
var result = scene.pack(child)
if result == OK:
    ResourceSaver.save("res://path/name.scn", scene) // or user://...
answered May 15 by volzhs (7,755 points)

Thank you for help.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.