Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - justin

Pages: [1]
1
Ok. I seem to have "fixed" that error. The problem had something to do with the scene manager cleaning up draw calls during scene unloading.

Here's my working code:

  1.         public IEnumerator LoadNextScene()
  2.         {
  3.             // load next scene
  4.             SceneManager.LoadScene(nextScene.ToString(), LoadSceneMode.Additive);
  5.  
  6.             // wait one frame for scene to load
  7.             yield return null;
  8.  
  9.             // set the active scene as soon as it's ready
  10.             var scene = SceneManager.GetSceneByName(nextScene.ToString());
  11.             SceneManager.SetActiveScene(scene);
  12.  
  13.             // move existing draw calls to new active scene
  14.             foreach(var dc in UIDrawCall.activeList)
  15.             {
  16.                 SceneManager.MoveGameObjectToScene(dc.gameObject, scene);
  17.             }
  18.  
  19.             foreach (var dc in UIDrawCall.inactiveList)
  20.             {
  21.                 SceneManager.MoveGameObjectToScene(dc.gameObject, scene);
  22.             }
  23.  
  24.             // unload previous scene
  25.             SceneManager.UnloadScene(previousScene.ToString());
  26.         }
  27.  

2
Like you said, it was a Unity issue after all.

After quite a bit of digging I managed to find a related bug on the Unity issue tracker: https://issuetracker.unity3d.com/issues/unloading-a-scene-can-destroy-non-instantiated-prefabs-that-are-indirectly-referred-to-by-other-currently-loaded-scene

I upgraded to Unity beta 5.4.0b5 and it fixed this issue.


Edit: The Null Reference Exception in the above post still occurs from time to time. At this point I have no clue if it's related or not.

3
Finally an error! This occurred in my main project where I first noticed the issue (again, only in standalone):

NullReferenceException
  at (wrapper managed-to-native) UnityEngine.Component:get_transform ()
  at UIDrawCall.get_cachedTransform () [0x00011] in ...\NGUI\Scripts\Internal\UIDrawCall.cs:185
  at UIPanel.UpdateDrawCalls () [0x001a6] in ...\Assets\NGUI\Scripts\UI\UIPanel.cs:1507
  at UIPanel.LateUpdate () [0x00080] in ...\NGUI\Scripts\UI\UIPanel.cs:1240

4
No luck.

Scene 1 has nothing except for the script attached in my original post. I mucked with the Clear Flags for every camera. I even removed all of the cameras except for the UI Camera in the second scene. All of the NGUI widget and camera settings are default, except for the clear flags which I tried every combination of.

This only seems to happen with NGUI widgets. The fact that it works in editor and fails silently in standalone builds is a huge problem and makes debugging a nightmare.  :-\

I set my UI Camera to render everything and tossed a cube in the scene, which gave me some weird results (screenshot attached).

Hopefully you have some more ideas. My original post has the example project attached if you want to see for yourself.

5
My project has 2 scenes.

Scene 1:
Immediately loads Scene 2 additively and then unloads itself.

Scene 2:
Displays a UI Sprite.

This works fine in editor. However, in Windows standalone builds, the sprite does not render in Scene 2.

This is the transition code:

  1.        
  2. IEnumerator Start()
  3. {
  4.         var op = SceneManager.LoadSceneAsync ("Scene2", LoadSceneMode.Additive);
  5.  
  6.         while (!op.isDone)
  7.         {
  8.                 yield return null;
  9.         }
  10.                        
  11.         SceneManager.UnloadScene ("Scene1");
  12. }
  13.  

Oddly, if I comment out the last line (SceneManager.UnloadScene), the sprite renders OK.

Unity version 5.3.2p1
NGUI version 3.9.6d

6
Aha, of course. Thanks.

7
I tried switching to 3D mode, reimporting the files, and building the atlas again. No luck.

8
I am experiencing this issue as well, even in a brand new empty project.

Unity 5.0.2f1
NGUI 3.9.0

This seems to only happen if the project was originally created in 2D mode.

Pages: [1]