Godot Version
4.3
Question
how should i use packedscene?
should i do like A or B or have better way to do it?
A :
1 - i make new autoload - name- PackedSceneManager
then i put dict/func
like this
var item_icon : Dictionary ={
"unknow" : preload("res://assets/ui/item_icon/unknowItem_32x32.png"),
### seed
"UnknowSeed": preload("res://assets/ui/item_icon/seed/unknow seed.png"),
"WheatSeed" : preload("res://assets/ui/item_icon/seed/wheatSeed.png"),
"TomatoSeed": preload("res://assets/ui/item_icon/seed/tomatoSeed.png"),
"WeedSeed" : preload("res://assets/ui/item_icon/seed/WeedSeed.png"),
"PineCone" : preload("res://assets/ui/item_icon/seed/pineSeed.png"),)
or like this
func get_plant_PackedScene( ID ) -> PackedScene :
var new_id
if ID is String:
new_id = ID
elif ID is Entity_ID_enum:
new_id = Entity_ID_enum.find_key( ID )
match new_id :
"DiePlant" : return preload("res://base resources/plant/DiePlant_ND.tscn")
"WheatPlant" : return preload("res://base resources/plant/WheatPlant_ND.tscn")
"TomatoPlant": return preload("res://base resources/plant/TomatoPlant_ND.tscn")
"WeedPlant" : return preload("res://base resources/plant/weed/WeedPlant_ND.tscn")
"PineTreePlant" : return preload("res://base resources/plant/pine tree/PineTree_ND.tscn")
_:
print("plant manager dont have this id")
return null
then when i need any of this i just take it
#####################################################################
B :
i just make new var in each Entity/obj like this
var WheatSeed := load("res://assets/ui/item_icon/seed/wheatSeed.png")
like when i destroy a plant, the plant will drop wheat seed, so just put var like this in plant.
and when i want to drop seed form inv , i do the same in inv slot.
#####################################################################
can someone tell me which one or another way to do more effectively? and what pro and con.
i also dont understand about saving and unsaving resource, ( i saw many video say something like this "if you do like this or like that you can save allot resorce " , they talking about memories?), just in case you talk about saving resouce pls explain bit to me.