I have a ScriptableObject that carries all default data values of the game.
I want to:
- Loop through the ScriptableObject’s PropertyInfo and set a CurrentPlayerData class to match its values.
- Load and overwrite the values of CurrentPlayerData if there a save is loaded/ else skip.
- Change values of fields in CurrentPlayerData as the game progresses.
- Save the changes of the CurrentPlayerData class to savedata.
- Repeat from 1) when game reboots.
//Match all current data to default data
foreach (var _fields in typeof(_CurrentPlayerData).GetFields())
{
_fields.SetValue(_currentData, _defaultData);
}
I know I’m not returning the correct type from this error:
ArgumentException: Object of type 'ProfileDataSO' cannot be converted to type 'System.String'.
How do I return the individual fields in ScriptableObject _defaultData?