- Home /
DontDestroyOnLoad->Go back 2 scenes *crashing*
I instantiate a prefab, then exit the game. I am then presneted with the exitgame scene (which shows players stats), I pause, and see that my prefab are visable in the inspector, I click on them and the mesh isn't there (it is invisable) but the boxcollider (along with the rest of the components) are present. Then I press 'esc' to load another scene and it crashes.
Nothing unusual is attached to this prefab that I am instantiating. The Transform component comes for free, I have a rigidbody, AudioSource, and BoxCollider Components.
Should I be saving the position in PlayerPrefs instead?
public class Script : MonoBehaviour {
private void Awake() {
//DontDestroyOnLoad(this); //Crashes Unity
DontDestroyOnLoad(transform.gameObject);//crashes Unity as well
}
}
It will probably be easier to help if you post the relevant scripts.
Your answer
![](https://koobas.hobune.stream/wayback/20220613103450im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
dondestroyonload problem 1 Answer
How do you transfer UI Text from one scene to another? 1 Answer
Currency System Not Saving!? 1 Answer
PlayerPrefs to save setActive state 2 Answers