Godot Version
v4.3.stable.steam [77dcf97d8]
Question
I am trying to implement a save game feature for my game.My code is as follows.I defined an object SaveData to serve as my game save entity but I found that the properties of my object must be annotated with @export in order to correctly read and store the values.
# save
var gameSave=FileAccess.open(SAVE_PATH,FileAccess.WRITE)
gameSave.store_var(var_to_bytes_with_objects(saveData),true)
#load
var gameSave=FileAccess.open(SAVE_PATH,FileAccess.READ)
var serialzeSave=gameSave.get_var(true)
var save:SaveData = bytes_to_var_with_objects(serialzeSave) as SaveData
#saveData
extends RefCounted
class_name SaveData
@export var scenePath:String
@export var playerHelth:float
@export var playerPos:Vector2
@export var enemyNodeArray:Array[Dictionary]