Context: A non-intrusive way to reload objects when their description file is changed
Focus: adding dynamic reloading of objects with minimal changes to the existing codebase
Function called by FileSystemWatcher
or alike:
void OnFileChanged(string filename, ...)
{
var old3 = GetAssetByFilename(filename);
var new3 = LoadAsset(filename);
...
Utils.CopyFields(new3, old3);
...
}
Notes:
- Cloning won't work because all objects would point to the old copy
- There are multiple multiple similar lists of assets
- Changing
LoadAsset
function is a no-go, there are multipleLoad*
functions to change - Changing
Asset
clases is no-go - Copying has to include private fields, etc.