I want my `Player` object to persist between levels, so I call this in the `Start()`
DontDestroyOnLoad(gameObject);
And while this worked, this started acting very very strange after the next level loaded. It turns out lots of things the player instance depended on were being destroyed. I ended up with this to make it right.
DontDestroyOnLoad(gameObject);
DontDestroyOnLoad(bullet);
DontDestroyOnLoad(explosion);
DontDestroyOnLoad(renderer.material);
for (var skill : Skill in skillComponents) {
DontDestroyOnLoad(skill);
}
So I had to mark all my prefab variables to not be destroyed as well as my material.
My question in why? Is there a rule of thumb about what should be marked dont destroy and what should not? The prefabs and objects stored in internal variables I almost get the need, but why on earth would my material need to be explicitly retained?