Author Topic: Pause panel works in Editor view but not in the final build!  (Read 4343 times)

Teku Studios

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 13
    • View Profile
    • Teku Studios
Hi there,

We're working with Unity Pro 4.1.2f1 and NGUI 2.6.1e (coding in C#) and we are experiencing a very weird issue. When we pause our game we enable a panel that acts as a pause GUI. Everything OK so far, it works perfect and the controls (keyboard-only) behave as expected. However, when we build our game (Windows x86 standalone), if we run it and press the "Pause" button, the pause panel only shows up in one of our scenes, in the rest of them the panel and its buttons are working and responding, but there's nothing on screen at all. Here's our setup:




In every scene, we have a unique UI Root (3D) object with a Pause Camera and a Pause Panel childed. Pause Camera is set to the same layer as the Pause Panel, and Pause Panel has its buttons and background objects childed. Also, Pause panel has an UIPanel component disabled by default. So, our player has a script that gets the pause input and enables the UIPanel component, so it shows on screen. Everything is correct until we build our game. Then, only Scene1 shows up the menu, the rest of the scenes have an operating yet invisible pause menu.

To prevent some cross-referencing issues when loading each scene, each time the player presses "Pause" his script looks in the current scene for "/UI Root (3D)/PausePanel" and gets its UIPanel component. It is not the most optimal way to handle this, but we coded it this way hoping to prevent this error from happening at runtime.

Any ideas on what is going on? We're getting nuts trying to figure out where does this issue come from. Thanks!


P.S.: We are playing the build at the exact same resolution as the editor Play window, so it shouldn't be related to that.
« Last Edit: May 28, 2013, 11:21:58 AM by Teku Studios »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Pause panel works in Editor view but not in the final build!
« Reply #1 on: May 28, 2013, 02:59:54 PM »
Are you scaling your panel from 0? Is the panel actually in front of the background? (negative Z?)

Teku Studios

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 13
    • View Profile
    • Teku Studios
Re: Pause panel works in Editor view but not in the final build!
« Reply #2 on: May 29, 2013, 03:21:16 AM »
We never scale anything from 0 when it comes to UI, we just enable/disable components. The panel, its background and the buttons are always the same size. Also, PausePanel is closer to the camera than the scenery, it's just located far away to the left.
« Last Edit: May 29, 2013, 03:28:03 AM by Teku Studios »

Teku Studios

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 13
    • View Profile
    • Teku Studios
Re: Pause panel works in Editor view but not in the final build!
« Reply #3 on: May 29, 2013, 06:52:55 AM »
Ok, we got it. Since the Editor view didn't throw any error or exception we hadn't noticed this. We have found where the problem lies while debugging a development build.

The player's script kept a reference to the previous scene's PausePanel, and that's why it wasn't working properly. So, instead of searching for the UI objects everytime the player presses "Pause" we now use our serialization methods to do so. This way, everytime the player loads a savegame or enters a new room, our Deserialize method gets the PausePanel of its current scene, just once, and then everything works as expected, even in the builds.