CodeBlanks Logo Icon CodeBlanks

Saving a scene

Learn to save a scene as a .tscn file.

Saving scenes and .tscn

You can save node trees you create in Godot as independent, reusable scenes. Godot stores text-based scenes using the .tscn (Text Scene) file extension. These files can be easily inspected both from the editor and file managers.

# Saved scene file path
var sahne_yolu = "res://Oyuncu.tscn"
print(sahne_yolu)

PackedScene Resource

Every .tscn file saved to disk is represented as a PackedScene resource in Godot's memory. PackedScene stores the scene hierarchy and all node properties as a packaged structure. This allows the scene to be quickly loaded into memory and used whenever needed.

var sablon: PackedScene
print(sablon == null)

Practice Print Scene Path

Inside _ready(), assign "res://Seviye.tscn" to the dosya_yolu variable and print it with print(dosya_yolu).

Starter code

Player.cs
extends Node

func _ready():
    # dosya_yolu değişkenini tanımlayıp yazdır
    pass

Sample solution

Player.cs
extends Node

func _ready():
    var dosya_yolu = "res://Seviye.tscn"
    print(dosya_yolu)

Expected output

res://Seviye.tscn

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 Which extension is used to save text-based scene files in Godot?

  • .blend
  • .gd
  • .tscn Correct answer
  • .unity

Explanation: Godot uses the .tscn extension for text-based scene files (.gd is for script files).

2 Specify PackedScene type

Question
var seviye_kaynagi: ____
Answer
var seviye_kaynagi: PackedScene

Explanation: The type that holds saved scenes in memory is PackedScene.

3 Scene Saving Components

Term Meaning
.tscn Text-based scene file extension
PackedScene Packaged scene resource data type
res:// Protocol for project root directory
Sahne Independent tree structure of nodes

All lessons in Beginner