Question by
Dubgron · Jan 03, 2016 at 09:21 AM ·
c#loadscene loadondestroy
Unexpected duplication of scene
Everytime when I started and finished testing a game in the hierarchy section this weird things appears http://scr.hu/3lxl/6i5g8. This is happening when this script is attached to player.
void OnDestroy() {
SceneManager.LoadScene("Main Scene");
}
How can I fix it? Sorry for my bad English. I'm not a native speaker :)
Comment
Best Answer
Answer by hexagonius · Jan 03, 2016 at 09:19 PM
do not use that kind of code in OnDestroy. if you must though, toggle a bool in OnApplicationQuit and check for it in OnDestroy first.
Your answer
Follow this Question
Related Questions
I can't figure out why my score doesn't save/increase 0 Answers
Save game - Tile based game 0 Answers
Save/Load Player System 0 Answers
C# SceneManager script not loading next scene after (seconds) 4 Answers
how to make a gaze work with a button? 0 Answers