You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you have an attached script that does @export var other_scene: PackedScene and you use this script on at least two scenes, then you set the PackedScene for each, in the editor, to point to each other (so it would make a circular reference kind-of), one of them will be null on runtime, and if you save it like this and reload the project, the scenes will become corrupted.
Steps to reproduce
Set up a scene with a Node2D as root.
Add a Timer that is set to autostart.
Attach a script to the root Node2D and fill the contents with:
extends Node2D
@export var other_scene: PackedScene = null
func _ready():
print("scene _ready()")
if other_scene:
$Timer.start()
else:
print("other_scene was null")
func _on_timer_timeout():
get_tree().change_scene_to_packed(other_scene)
Connect the timeout signal of the Timer to the _on_timer_timeout() function.
Duplicate this scene and save it as something else.
Edit root node's exported PackedScene property to reference the duplicated scene.
Edit the duplicated scene and also edit it's root node to reference the original scene.
Run and watch as it loads the duplicated scene, but prints
scene _ready()
scene _ready()
other_scene was null
after the duplicated scene is loaded.
Minimal reproduction project
This is the project just before completing Step 7. Completing Step 7 will cause the scenes to become corrupted and you can no longer open the scenes, so you must do Step 7 to see the bug. ExportPackedSceneBug.zip
The text was updated successfully, but these errors were encountered:
Just experienced this in 4.1.2 unfortunately. Doors have a packed scene export to the room they connect to. Suddenly got an error that one scene was null, then both went corrupt. Super frustrating :(
I've had corruption issues with @tool Resource scripts that utilize @export PackedScene as well. For example, having a Monster Resource with an @export PackedScene pointing to a model or Node3D or something.
Godot version
v4.1.1.stable.arch_linux
System information
Godot v4.1.1.stable unknown - EndeavourOS #1 SMP PREEMPT_DYNAMIC Wed, 19 Jul 2023 19:19:38 +0000 - Vulkan (Mobile) - dedicated NVIDIA GeForce GTX 1070 (nvidia; 535.86.05) - Intel(R) Core(TM) i5-8400 CPU @ 2.80GHz (6 Threads)
Issue description
When you have an attached script that does
@export var other_scene: PackedScene
and you use this script on at least two scenes, then you set the PackedScene for each, in the editor, to point to each other (so it would make a circular reference kind-of), one of them will be null on runtime, and if you save it like this and reload the project, the scenes will become corrupted.Steps to reproduce
after the duplicated scene is loaded.
Minimal reproduction project
This is the project just before completing Step 7. Completing Step 7 will cause the scenes to become corrupted and you can no longer open the scenes, so you must do Step 7 to see the bug.
ExportPackedSceneBug.zip
The text was updated successfully, but these errors were encountered: