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

PixelEnvision

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 35
    • View Profile
    • Pixel Envision
Hi,

"Scene is being destroyed while there are hidden renderers that are using it. This is likely an editor script creating objects with hideFlags and leaving them enabled."

I know there are other threads about this but my case is a bit different. I'm not getting this when working on editor. Playing/stopping on editor is error free. But error pops up at log cat when the application is running on android device.

I've already tried (Which I always doing) "proper" import of latest NGUI.

Any suggestions?
Pixel Envision - Creating fun apps for iOS & Android

Twitter / Facebook / YouTube

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Off the top of my head I got nothing. You might need to debug this one...

PixelEnvision

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 35
    • View Profile
    • Pixel Envision
Off the top of my head I got nothing. You might need to debug this one...

Ok thanks....

I'm currently taking the scene apart.. I'll post here if I find anything useful...
Pixel Envision - Creating fun apps for iOS & Android

Twitter / Facebook / YouTube

PixelEnvision

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 35
    • View Profile
    • Pixel Envision
Aren,

It looks like that is triggered buy UISprite.cs, any idea which part would it be?

If I disable UISprite script components in my scene, error goes away. Nothing else was changed including Other NGUI scripts or GUI tree, etc...
Pixel Envision - Creating fun apps for iOS & Android

Twitter / Facebook / YouTube

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
The error says "editor script". Editor scripts shouldn't even run outside the unity editor, so I'm not sure what's up with that. I doubt it's UISprite. More likely it's any widget, as geometry gets created by UIDrawCall script which is created by UIPanel when generating procedural geometry to draw the UI.

PixelEnvision

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 35
    • View Profile
    • Pixel Envision
I see... Well, I'm still trying to pin point exact part causing this.

Just tried an empty scene with only 3 NGUI objects UIRoot>Camera>UISprite, I guess that's the minimum to get sprite displayed and problem still exists..

I'll try a sliced sprite now to see if it's the same...
Pixel Envision - Creating fun apps for iOS & Android

Twitter / Facebook / YouTube

PixelEnvision

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 35
    • View Profile
    • Pixel Envision
Just a follow-up...

After testing some widgets, I've finally come to UITexture, which also bypasses atlases, etc...

This is is the current setup
-UIRoot
--Camera
---Panel
----UITexture

Error is still there... I've disabled the UIRoot script and UITexture itself seems innocent. I don't know how NGUI works but I feel like it might be the UIPanel.

I'll check if that also happens on iOS builds...
Pixel Envision - Creating fun apps for iOS & Android

Twitter / Facebook / YouTube

PixelEnvision

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 35
    • View Profile
    • Pixel Envision
I should have read your post properly before wasting time on trying widgets.  :)

Anyway, I've taken a look at UIDrawCall script and noticed you were using HideFlags.DontSave.

There were 4 in UIDrawCall and 1 in UIPanel.

I've commented out those, it looks like the ones in UIDrawCall had no problem but the one in UIPanel line 509 fixed the issue!  go.hideFlags = HideFlags.DontSave;

After searching the project for DestroyImmediate calls, I couldn't find a call for object "go" while other 4 had destroy calls set. I guess that was the culprit...

Since I commented out that line blindly, I'm afraid it might have some side effects since you've used it... If that's the case, where should I place the destroy call?

Best,
Erdener
Pixel Envision - Creating fun apps for iOS & Android

Twitter / Facebook / YouTube

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Line 549: if (dc != null) NGUITools.DestroyImmediate(dc.gameObject);

The draw calls get destroyed when the panel gets OnDisable notification.

Without the hide flag being set, the UI will not persist while switching scenes, which is bad if you are expecting to have a loading screen that fades out when the new scene loads in or something along those lines. I've also had it switched to DontDestroyOnLoad(go) instead, but I think that caused some other set of issues.

PixelEnvision

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 35
    • View Profile
    • Pixel Envision
Line 549: if (dc != null) NGUITools.DestroyImmediate(dc.gameObject);

The draw calls get destroyed when the panel gets OnDisable notification.

Without the hide flag being set, the UI will not persist while switching scenes, which is bad if you are expecting to have a loading screen that fades out when the new scene loads in or something along those lines. I've also had it switched to DontDestroyOnLoad(go) instead, but I think that caused some other set of issues.

I see your point...

If I get that right I can keep it that way (comment out) or place a destroy for go in OnDisable. But with that way, I will loose the ablity of keeping the UI live between scenes..

Maybe that can be a panel option sometime in the future? "Keep this panel persist" or something... :)
Pixel Envision - Creating fun apps for iOS & Android

Twitter / Facebook / YouTube

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Try replacing that hide flag setting with DontDestroyOnLoad instead. See if that helps.

quitebuttery

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 18
    • View Profile
I have this same error since I upgraded to the latest version (I think I was a few weeks behind in updates).  I have some disabled widgets that are referenced by scripts (I enable/disable them to hide/show different panels, buttons, etc.)  I figured this was the cause of it?

disturbing

  • Guest
Try replacing that hide flag setting with DontDestroyOnLoad instead. See if that helps.

This worked.  I was having an issue /w mobile builds.  This seems to be working fine and I still have persistent loading screen working between scenes.

Be sure to put this in an update if it hasn't already. 

I'm using v 2.0.7c

~DisTurBinG

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Seems like it's an inconsistency in Unity's behaviour. Good to know, thanks.

capitalj

  • Jr. Member
  • **
  • Thank You
  • -Given: 5
  • -Receive: 0
  • Posts: 88
    • View Profile
Hi guys,

I'm getting the same error come up but on only iOS builds of the game and never in the editor:

Scene is being destroyed while there are hidden renderers that are using it. This is likely an editor script creating objects with hideFlags and leaving them enabled.

I don't really want to change any of the NGUI code as it will create problems down the line with updating NGUI versions. I noticed the error comes up when changing scenes. My first scene (main menu) just has a simple ngui setup:
Root->Camera->Anchor->Panel->Buttons

The 2nd (main gameplay) scene has 2 NGUI roots and hierarchies, one is for a full screen character menu and the other is for all other in game UI. The way I switch between these 2 UIs in the main scene is by disabling the Camera for one of the GUIs and enabling the camera for the other one. Maybe that's not the right way to do that?

I also didn't get this error before updating to the latest 2.0.8 version.

-JJ