Load Scene Replay Problem
Hi Guys,
I am completeley new on Unity and still trying to develop. For each Project I am trying to complete, it would be easier but every time I stuck in one point.
This time, I have a game, and after game over, a panel is activated and a button asks for a Replay game. I have attached a replay function that loads that scene again. ( only one scene included in the game) i play the game, game over happens and i click replay. Scene is loaded again but this time i have a great problem that all my buttons lost its functions attached to them.
I have developed a few small projects but I am seeing this problem first time. I am handling with my Project over a week and I want it to work as well.
what is my problem, why i am loosing all my scripts attached to my buttons ?
I will be very appreciated if you help me. thanks in advance.
Answer by Dudicus · Jul 05, 2016 at 01:51 AM
What's your script to reload the scene? Try using:
Application.LoadLevel("levelnamehere");
And you can use that method to reload the scene you are still on, and/or other scenes. It may say it is "obsolete" but don't worry. It won't cause you an errors at any point!
Yes I am using " Application.LoadLevel("levelnamehere"); " . It loads level again. Here is the schema, When I first start the game;
Play game -----> Play ends,
Game Over panel asks to Play Again? with a button ------->
Scene loads again, everything on its on way,
but the Play button in the 1. step does not working after loading the same scene again. Also buttons are loosing the methots that attached to them.
Your answer
Follow this Question
Related Questions
Unable to trigger the onClick event of a game object with a run-time listener. 1 Answer
I cant assign a function to a button. *free candy for whoever helps me out* 2 Answers
Adding listeners buttons in for loop 0 Answers
Player Upgrade Screen - Button Upgrades keep resetting! 0 Answers
Giving a UI button a Color at Start 0 Answers