idk if this is a godot 4 bug but everytime i preload a scene, if you try to open that scene from the editor, it says this:
Failed to instantiate scene state of “res://scenes/card.tscn”, node count is 0. Make sure the PackedScene resource is valid.
one more thing is this:
Failed loading resource: res://scenes/card.tscn. Make sure resources have been imported by opening the project in the editor at least once.
what is going on? it only happens when you use ‘preload(“res://scene.tscn”)’
Not sure if it’s the same issue, as you said you’re trying to open from the editor, but I was having this error at runtime. I was using const to preload a .tscn in the script of that same scene. Because I wanted to do: tree.change_scene_to_packed(OtherScene.scene)
When I changed it to static var, it worked.
I suppose it may be a cyclic dependency issue, as the .tscn references the .gd script, and the script preloads that same tscn. I think if you make it a dependency with const, it tries to preload a tscn that hasn’t finished resolving yet, and it ends up being null. This is a very lame issue IMO; the engine should be able to handle that gracefully, but I guess it doesn’t.