Godot Version
4.2.1
Question
Hello, in my game i’m trying to save player data, specifically placed item data. This is currently working when I debug/run it on my laptop but something strange is happening when exported to IOS.
The reason I’m pretty sure it’s the subresources not loading is because it saves and loads the money and rebirths fine when exported but inventory and placed_items doesn’t either load or save correclty - but it does work fine when not in the export version.
Here’s the code for saving:
PlayerData.gd
extends Resource
class_name PlayerData
@export var money: float
@export var rebirths: int
@export var inventory: Dictionary
@export var placed_items: Array[PlacedItemData]
PlacedItemData.gd
extends Resource
class_name PlacedItemData
@export var item_index: int = -1
@export var rotation: float = 0
@export var position: Vector2i = Vector2i.ZERO
var instance: Node2D = null
SaveHandler.gd
func load_data() -> Resource:
if ResourceLoader.exists(save_path):
print("found save file")
var res: Resource = ResourceLoader.load(save_path, "", ResourceLoader.CACHE_MODE_IGNORE)
if res: return res
print("error with save file?")
print("new save file")
var data: PlayerData = PlayerData.new()
data.inventory = {}
data.placed_items = []
return data
func save_data(data) -> void:
print('saving to file')
var response: int = ResourceSaver.save(data, save_path, ResourceSaver.FLAG_CHANGE_PATH)
print("save response: " + str(response))
assert(response == OK)