Quantcast
Channel: Questions in topic: "dontdestroyonload"
Viewing all articles
Browse latest Browse all 416

how to disable dontdestroyonload on a specific scene

$
0
0
hey, i'm making a 2d game that contains bonus scenes, so i manage to put my score to go over the scenes and don't destroy, so it would have the same value when the player went back to the main scene. here's the problem: when the player dies, the score does not reset. how can it make it reset when the player is dead? obs: the game over menu has a restart button and i tried to add something to his script, but it didn't work. the restart button script: public class LoadSceneOnClick : MonoBehaviour { public void LoadByIndex(int sceneIndex) { SceneManager.LoadScene (sceneIndex); } } the dontdestroyonload script: public class SaveScore : MonoBehaviour { void Awake () { DontDestroyOnLoad (this); if (FindObjectsOfType (GetType ()).Length > 1) { Destroy (gameObject); } } } thanks in advance c:

Viewing all articles
Browse latest Browse all 416

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>