Question on prefabs

I haven’t yet implemented a saving system to my game yet, but when I get to it i will probably be using a JSON system (not sure if this makes any difference to my question).

My game has multiple playable characters, and multiple weapons and items etc. When a level starts the equipped characters and weapons get instantiated from the necessary prefabs. When I implement a save function is it possible to save new variables to my character and weapon prefabs? I only ask as I am thinking that I will run into issues where data is only saved for a specific instance of an object, which will cause issues for my game as these objects are not always going to be in the scene.

I would probably store the items as “ID’s” and map them as an index to some array library of components, then instance components into place by those ID’s when the game starts.

This is something I already have in place. I have an itemDatabase which is a scriptable object of class Item. The item class includes an itemID and an itemPrefab, and it is this which is used to instantiate the object. My question still stands though, as to whether the updated variables will save to the prefabs

Not at runtime. If the ID’s change then you’ll have to save the values somewhere and reference them. PlayerPrefs is the easiest way.

Sorry for not being clear, it’s not the ID’s that will change. They are stored in a database and are just a reference to an item. The prefab instantiated from the itemPrefab will have its own scripts on it containing variables such as level and other statistics that will constantly be changing while the user plays the game.