A problem about Resource, How do I fix it?

Godot Version

4.2.1 stable

Question

When I open the inspector, I get endless errors

Resource file not found: res://PlayerData.tres::Resource_q5ir7 (expected type: )
Resource file not found: res://PlayerData.tres::Resource_q5ir7 (expected type: )
Resource file not found: res://PlayerData.tres::Resource_q5ir7 (expected type: )
Resource file not found: res://PlayerData.tres::Resource_q5ir7 (expected type: )
Resource file not found: res://PlayerData.tres::Resource_q5ir7 (expected type: )
.....

This is my tres file:

[gd_resource type="Resource" script_class="PlayerData" load_steps=8 format=3 uid="uid://bgvvws3qtugqv"]

[ext_resource type="Script" path="res://equipments_resource.gd" id="1_5dipn"]
[ext_resource type="Script" path="res://bag_resource.gd" id="2_cw487"]
[ext_resource type="Script" path="res://bag_item.gd" id="2_putg8"]
[ext_resource type="Script" path="res://player_data.gd" id="3_xu5ld"]

[sub_resource type="Resource" id="Resource_0n60t"]
resource_name = "equip_bag"
script = ExtResource("1_5dipn")
equipments = []
bag_name = "E_Bag"

[sub_resource type="Resource" id="Resource_q5ir7"]
script = ExtResource("2_putg8")
amount = 1

[sub_resource type="Resource" id="Resource_wypj1"]
script = ExtResource("2_cw487")
items = [SubResource("Resource_q5ir7")]


[resource]
resource_name = "player_data"
script = ExtResource("3_xu5ld")
username = "aaa"
item_bag = SubResource("Resource_wypj1")
equip_bag = SubResource("Resource_0n60t")

This is my script:

extends BaseResource
class_name PlayerData

@export var username:String :
	set(new_value):
		if not username:
			username = new_value
		if not new_value == username:
			username = new_value
			emit_changed()
			save_as_resource()
@export var item_bag:BagResource:
	get:
		if not item_bag:
			item_bag = BagResource.new()
		return item_bag
@export var equip_bag:EquipmentResource:
	get:
		if not equip_bag:
			equip_bag = EquipmentResource.new()
		return equip_bag

It’s talking about this. In wich I’m not sure what this is script and exported value is in reference to from above.

I think your problem is elsewhere and is not in the code you have provided.

This is my BagResource Script

extends Resource
class_name BagResource

@export var items: Array

@export_group("container param")
@export var check_slot_count:bool = true 
@export var max_slot_count:int = 20
@export var check_weight:bool = false 
@export var max_weight:int = 100  
@export var default_stuck_size:int = 100 
@export_group("")

var item_database: ItemDatabaseResource
var weight_now:float = 0
var count_now:int :
	get:
		return items.size()

This is my BagItem Script

class_name BagItem extends Item

@export var amount: int

And this is my Item Script

extends Resource
class_name Item

@export var id: int
@export var icon: String
@export var name: String
@export var type: String
@export var info: String
@export var stuck_size: int

I don’t understand where it would lead to an error

I just ran into this error myself. I think it was related to a parent being deleted while operating with new children.

the other thing it could be is that the .godot folder cache is now not aligned.

you could try running this script which should resave your files.

# script goes through project resaving files in editor resolving invalid UID issues
# open script in editor and run with right-click 
@tool
extends EditorScript

var files: Array[String]

func _run() -> void:
	files = []

	add_files("res://")

	for file in files:
		print("fix_uid: ",file)
		var res = load(file)
		ResourceSaver.save(res)

func add_files(dir: String):
	for file in DirAccess.get_files_at(dir):
		if file.get_extension() == "tscn" or file.get_extension() == "tres" or file.get_extension() == "material":
			files.append(dir.path_join(file))

	for dr in DirAccess.get_directories_at(dir):
		add_files(dir.path_join(dr))

The second option, you could also try deleting the .godot folder and restarting the editor.

Warning

if you do decide to try this option, it could cause you to have to reimport textures if they had custom import settings.

I just deleted the .godot folder and then re-imported the project and everything works fine now, thank you very much for your help

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.