I was following this tutorial of how to make a inventory system in Godot, (here) and I encountered an error when I ran it at 11:25 in the video. The particular error is “Node not found: “Icon” (relative to “PanelContainer”)” and in stack trace it says “Invalid access to property or key ‘Icon’ on a base object of type ‘Resource (Item)’”. Can I get any help on this? The code for my project is below. I’m new to coding in Godot so sorry if this is a simple fix.
Item Script
extends Resource
class_name Item
@export var title: String
@export var icon : Texture2D
@export_multiline var description : String
Inventory Slot Script
extends PanelContainer
@export var item : Item:
set(value):
item = value
$Icon.texture = item.Icon
func _on_mouse_entered():
if item != null:
owner.set_description(item)
Ui Script
extends Control
@export var description : NinePatchRect
func set_description(item: Item):
description.find_child("Name").text = item.title
description.find_child("Icon").texture = item.icon
description.find_child("Description").text = item.description
It’s so uncomfortable to see your description.
What do capped and uncapped mean?
I just misread and thought put the Item directly into the node tree.
You used exported variables, So should pay attention to the operation.
Before replacing resources, it is necessary to check whether the node has completed loading.
Also need to replace the entire resource.
eg:
var it=Item.new()
it.icon=Texture2D.new()
it.title="new title"
it.description="new description"
if is_node_ready():
item=it