Author Topic: Scene is being destroyed while there are hidden renderers that are using it.  (Read 15151 times)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Ignore it for now or just change the code. The next update will have the same changes.

MetaMythril

  • Guest
I'm getting this same issue from UIPanel as it is NGUI is being used by the Spriter API.

It seems like my scene is corrupted as whenever I save the scene, objects appear to render that have no game object tied to them.

Any idea when an official fix will be released? I tried to follow along with the suggested fixes but I'm not sure what was actually commented out / disabled or what code was replaced where with what. :P

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
It has already been released. 2.0.9.

dlewis

  • Guest
It has already been released. 2.0.9.

I just updated to 2.0.9 and have only just started getting this issue now (on pc). The easiest repro is to destroy the current scene (either stop playback or load a new scene either with the game running [Application.LoadLevel] or even just loading it from the editor without the game running) but I have seen it a few times when just running a scene.

You were talking about how the flags will allow the UI to persist through scenes but when testing changing scenes the UI from the first scene is lost when transitioning to the 2nd scene (I've also been using it with that limitation in mind, so my UI is loaded additive into my scenes).

Any more ideas on how to fix it?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
I am using 2.0.9 daily as I work on Windward, and I've yet to see this issue. I switch scenes all the time, both in the editor and while the game is running without any issues. Have you tried restarting Unity since you updated?
« Last Edit: August 01, 2012, 04:01:03 PM by ArenMook »

Wahooney

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 31
    • View Profile
I think the reason I'm getting this error is because I'm additively loading levels. Then when I stop the player, I get this error.

Aronmook, I think this is related to this: http://www.tasharen.com/forum/index.php?topic=634.0;topicseen

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Possibly... I load them the normal way.

GavinF

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 16
    • View Profile
For what it's worth, I got this error after upgrading NGUI from 2.0.9 to 2.1.4 using the manual 'delete NGUI folder and import new package' method.  I was also having strange issues with widgets being drawn while they were inactive.  All of my issues were resolved by simply shutting down the Unity editor and opening it back up after doing the update.  Something to try if you haven't already figured this one out.

nzen

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 30
    • View Profile
I just had this issue. Restarting the editor for me fixed the "Scene is being destroyed..." issue. It was strange. It had a "ghost" version of the GUI there saved from when I had stopped playing, even when I disabled every object in the editor.

When I played again I had another error:
MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it.

The solution was adding an if condition to the OnDisable:
  1. void OnDisable()
  2. {
  3.         if (theButton)
  4.                 UIEventListener.Get(theButton).onClick -= ButtonReciever;
  5. }

But then I got this error:
Destroying object immediately is not permitted during physics trigger and contact callbacks

All I was doing was a "NGUITools.SetActive" on a panel stored in a variable that was currently enabled.

The SetActive was inside an event reciever which checks the game state, and if it's a certain state, does SetActive.

  1. void StateChanged(GameState gameState)
  2.         {
  3.                 if (gameState == GameState.GameCompleted)
  4.                 {
  5.                         NGUITools.SetActive(progressBarPanel, false);
  6.                 }
  7.         }

The state is changed by touching a trigger which increments a value, if that value == something, it sends an event. Then GameStateManager listens to the event and sends its StateChanged event.

The solution to that is here - http://www.tasharen.com/forum/index.php?topic=1417.0 (delay the SetActive by a frame)

Create an intermediary function you send it it like so:

  1. IEnumerator SetActive(GameObject go, bool state)
  2. {
  3.         yield return new WaitForSeconds(Time.deltaTime);
  4.         NGUITools.SetActive(go, state);
  5. }

Then use:
StartCoroutine(SetActive(progressBarPanel, true));

Maybe there is a better way.
« Last Edit: January 24, 2013, 07:02:36 PM by nzen »

lzjamaoge

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
ha...I face this problem after I update NGUI. When I change the scene it occurs! I try to restart Unity3d, then it works!