Whenever I launch my Godot 4 project, some specific scenes in my game will corrupt themselves, such that whenever I try to open the scene it displays a popup with the text:
Scene file 'scene.tscn' appears to be invalid/corrupt
.
In the console this error message is also displayed upon attempting to open the scene in the editor.
Failed to instantiate scene state of "scene.tscn", node count is 0. Make sure the PackedScene resource is valid.
I am not sure what is causing this, it will happen without me changing the scene at all, just opening and closing the editor. Most importantly, the project still runs perfectly fine, I am able to see the scenes within my game running normally when I test it, while the files are supposedly corrupted.
This is an example of what one of the corrupted scene files looks like:
[gd_scene load_steps=2 format=3 uid="uid://wenmbpbqeikr"]
[ext_resource type="Script" path="res://Creatures/CreatureBody.gd" id="1_2l5r3"]
[node name="CreatureBody" type="Node2D"]
script = ExtResource("1_2l5r3")
[node name="Shapes" type="Node2D" parent="."]
[node name="Legs" type="Node2D" parent="."]
[node name="Camera" type="Camera2D" parent="."]
So far the only consistent fix I have for this issue is to delete the scene and create a new identical one from scratch, however this is becoming tedious.
I have tried restarting the project, sometimes it fixes it but more often than not the scene remains corrupted.
I have tried deleting the .godot folder, making the project rebuild itself, and then seeing if the new built scene is not corrupted, but this also does not work. any help here would be greatly appreciated.