I am loading my assets and tile information through YAML files.
While working on the game, I needed to quickly change some values and test them in-game, and I realized I could just re-load the YAML information without having to restart.
However, before my files are processed by my YAML parser, they are loaded by using Resources.LoadAll
, like this:
foreach (var buildingTileType in Resources.LoadAll(Settings.BUILDING_TILES_PATH, typeof(TextAsset)))
{
var buildingTile = Deserializer.Deserialize<BuildingTile.Initializer>(((TextAsset) buildingTileType).text);
BuildingTileInstances.Add(buildingTile.Name, buildingTile.CreateInstance());
}
When I want to reload my defs, I clear the BuildingTileInstances
dictionary and call the def-loading method again. However, I noticed the values were remaining the same until I restarted the game.
I've read that Resources.Load actually caches your files for optimization, and in this case, I'd like to somehow clear that cache to allow for live reloading.
I've tried using Resources.UnloadUnusedAssets()
and Caching.ClearCache()
, but none of them worked. Is there any way to achieve this?