Saving tscn in a script

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

I want to save a scene in the script. Is there any way I can do this?

From what I understand, I can get the node’s tree and try to save it in a Resourcesaver

The tree can be saved to a PackedScene. But the nodes involved have to be owned by the root node (or at least the parent node with child nodes). If the owner property of the nodes isn’t that of the root node, then the node will be left out of the saved scene.

Ertain | 2021-04-14 07:20

:bust_in_silhouette: Reply From: exuin

You’re looking for a PackedScene PackedScene — Godot Engine (stable) documentation in English

:bust_in_silhouette: Reply From: Mrpaolosarino

export(PackedScene) var Scene.
you can access the export var directly in your editor so it’s versatile