Author Topic: Game Over Menu back to Start Menu problem  (Read 3585 times)

Bissmark

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Game Over Menu back to Start Menu problem
« on: October 25, 2013, 05:38:45 AM »
Hi, I am quite new to NGUI

I am trying to create a Game Over menu which works fine. I quit back to the main menu
But when I try and play the game again I get errors saying that items have been destroyed

Please help

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Game Over Menu back to Start Menu problem
« Reply #1 on: October 25, 2013, 04:03:36 PM »
Have you tried not destroying those game objects..? :P

It sounds like there's a problem with how you're handling a game being over, so things that were destroyed during the game or when it finished aren't re-initialized or remade when you want to play again.

Bissmark

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: Game Over Menu back to Start Menu problem
« Reply #2 on: October 26, 2013, 01:00:13 AM »
I do not actually believe I delete the objects, I thought that they just got deleted when the scene changed back to
the menu. At the moment on game over everything gets disabled and then enabled again on game start. I am frantically trying to find if the objects are destroyed somewhere but there isent that much code to work through and I cannot find it anywhere.
Its easier for my retry button because then it doesnt have to change scenes, it can just trigger the gamestart again and work from there.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Game Over Menu back to Start Menu problem
« Reply #3 on: October 26, 2013, 05:40:52 AM »
Ok, well, anything that isn't marked as DontDestroyOnLoad in the scene will be destroyed when the scene changes http://docs.unity3d.com/Documentation/ScriptReference/Object.DontDestroyOnLoad.html

I'd recommend you set the root object of your UI to be that, so it persists.

Bissmark

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: Game Over Menu back to Start Menu problem
« Reply #4 on: October 26, 2013, 05:58:36 AM »
I have tried to use DontDestroyOnLoad before but it seems that the error comes before the awake function
so when I use DontDestroyOnLoad on my player, then i get more problems because it duplicates