1. On your enemies, start the DestructibleSaver keys with "destructible_".
2. Edit SavedGameData.cs and add this at line 50:
Code: Select all
public Dictionary<string, SaveRecord> Dict { get { return m_dict; } }
3. Use this script:
Code: Select all
public class RespawnEnemiesOnLoadGame : MonoBehaviour
{
public static bool isLoadingGame;
void Start()
{
SaveSystem.loadStarted += OnLoadStarted; // We want to know when SaveSystem is loading a game.
}
void OnDestroy()
{
SaveSystem.loadStarted -= OnLoadStarted;
}
void OnLoadStarted()
{
SaveSystem.sceneLoaded += OnSceneLoaded; // When loading game, we want to know when scene is loaded.
}
void OnSceneLoaded(string sceneName, int sceneIndex)
{
SaveSystem.sceneLoaded -= OnSceneLoaded;
// After scene is loaded when loading a game, remove all keys that start with "destructible_".
var destructibleKeys = new List<string>();
foreach (var key in Dict.Keys)
{
if (key.StartsWith("destructible_")) destructibleKeys.Add(key);
}
destructibleKeys.ForEach(key => SaveSystem.currentSavedGameData.DeleteData(key));
}
}