Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.


Inherits: Resource < Reference < Object

Inherited By: PackedSceneGLTF

Una abstracción de una escena serializada.


A simplified interface to a scene file. Provides access to operations and checks that can be performed on the scene resource itself.

Can be used to save a node to a file. When saving, the node as well as all the nodes it owns get saved (see owner property on Node).

Note: The node doesn't need to own itself.

Example of loading a saved scene:

# Use `load()` instead of `preload()` if the path isn't known at compile-time.
var scene = preload("res://scene.tscn").instance()
# Add the node as a child of the node the script is attached to.

Example of saving a node with different owners: The following example creates 3 objects: Node2D (node), RigidBody2D (rigid) and CollisionObject2D (collision). collision is a child of rigid which is a child of node. Only rigid is owned by node and pack will therefore only save those two nodes, but not collision.

# Create the objects.
var node =
var rigid =
var collision =

# Create the object hierarchy.

# Change owner of `rigid`, but not of `collision`.
rigid.owner = node

var scene =
# Only `node` and `rigid` are now packed.
var result = scene.pack(node)
if result == OK:
    var error ="res://path/name.scn", scene)  # Or "user://..."
    if error != OK:
        push_error("An error occurred while saving the scene to disk.")





{"conn_count": 0,"conns": PoolIntArray(  ),"editable_instances": [  ],"names": PoolStringArray(  ),"node_count": 0,"node_paths": [  ],"nodes": PoolIntArray(  ),"variants": [  ],"version": 2}



can_instance ( ) const


get_state ( )


instance ( GenEditState edit_state=0 ) const


pack ( Node path )


enum GenEditState:

  • GEN_EDIT_STATE_DISABLED = 0 --- Si se pasa a instance, bloquea las ediciones al estado de la escena.

  • GEN_EDIT_STATE_INSTANCE = 1 --- Si se pasa a instance, proporciona recursos de la escena local a la escena local.

Nota: Sólo disponible en las construcciones de los editores.

  • GEN_EDIT_STATE_MAIN = 2 --- Si se pasa a instance, proporciona recursos de la escena local a la escena local. Sólo la escena principal debe recibir el estado de edición principal.

Nota: Sólo disponible en las construcciones del editor.

  • GEN_EDIT_STATE_MAIN_INHERITED = 3 --- It's similar to GEN_EDIT_STATE_MAIN, but for the case where the scene is being instantiated to be the base of another one.

Note: Only available in editor builds.

Descripciones de Propiedades


{"conn_count": 0,"conns": PoolIntArray(  ),"editable_instances": [  ],"names": PoolStringArray(  ),"node_count": 0,"node_paths": [  ],"nodes": PoolIntArray(  ),"variants": [  ],"version": 2}

Una representación en el diccionario del contenido de la escena.

Las claves disponibles incluyen "rnames" y "variants" para los recursos, "node_count", "nodes", "node_paths" para los nodos, "editable_instances" para las anulaciones de hijos de la escena base, "conn_count" y "conns" para las conexiones de señales, y "version" para el estilo de formato de la PackedScene.

Descripciones de Métodos

  • bool can_instance ( ) const

Devuelve true si el archivo de la escena tiene nodos.

Devuelve el SceneState que representa el contenido del archivo de la escena.

Instala la jerarquía de nodos de la escena. Desencadena la(s) instanciación de la(s) escena(s) hij(as). Dispara una notificación Node.NOTIFICATION_INSTANCED en el nodo raíz.

Pack ignorará cualquier subnodo que no pertenezca a un nodo determinado. Ver Node.owner.