Loop through ScriptableObject data to set default data.

I have a ScriptableObject that carries all default data values of the game.

I want to:

  1. Loop through the ScriptableObject’s PropertyInfo and set a CurrentPlayerData class to match its values.
  2. Load and overwrite the values of CurrentPlayerData if there a save is loaded/ else skip.
  3. Change values of fields in CurrentPlayerData as the game progresses.
  4. Save the changes of the CurrentPlayerData class to savedata.
  5. 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?

Basically, because I’m copying a properties from one class to a different class, I have to loop through each properties within each class and set the value that way.

System.Reflection.PropertyInfo[] _defaultProperties = _defaultData.GetType().GetProperties();
        System.Reflection.PropertyInfo[] _currentProperties = _currentData.GetType().GetProperties();

        ////Match all current data to default data
        foreach (System.Reflection.PropertyInfo _defProperty in _defaultProperties)
        {
            foreach (System.Reflection.PropertyInfo _curProperty in _currentProperties)
            {
                if (_defProperty.Name == _curProperty.Name && _defProperty.PropertyType == _curProperty.PropertyType)
                {
                    _curProperty.SetValue(_currentData, _defProperty.GetValue(_defaultData));
                    break;
                }
            }
        }