Author Topic: Application.LoadLevel causing very strange behavior on the iPhone  (Read 11284 times)

dex_scott

  • Guest
Hello,

Im using Application.LoadLevel to change scenes.  This works fine in the editor but when I try it on the iPhone, the UI from the previous scene stays on the screen.  I cant figure out what exactly is going on.

Im not 100% positive this is an NGUI issue but some other topics mentioned about it.  I just upgraded to the latest NGUI hoping to fix it, but no dice.

Any idea what may be causing it to hold on to the other scenes UI?  Im not setting any flags to keep the object on destroy.  Thanks.

joreldraw

  • Guest
Re: Application.LoadLevel causing very strange behavior on the iPhone
« Reply #1 on: June 13, 2012, 04:04:15 AM »
If you have unhidden objects in your menu sometimes when you modify this, need to reopen each scene and off what you like.
I take this error too, on editor is off but on the tablet appear on.


dex_scott

  • Guest
Re: Application.LoadLevel causing very strange behavior on the iPhone
« Reply #2 on: June 13, 2012, 04:10:05 AM »
Im not sure exactly what you mean..Do you mean re-opening the scenes and toggling enabled?

joreldraw

  • Guest
Re: Application.LoadLevel causing very strange behavior on the iPhone
« Reply #3 on: June 13, 2012, 04:14:11 AM »
Yes, reopen the scene with error  and set Disable what you need again with her childrens.

dex_scott

  • Guest
Re: Application.LoadLevel causing very strange behavior on the iPhone
« Reply #4 on: June 13, 2012, 04:23:03 AM »
Hmm I tried enabling/disabling everything and re-opening the scenes, but the same problem remains.  On scene change the interfaces "stack" on top of each other.

joreldraw

  • Guest
Re: Application.LoadLevel causing very strange behavior on the iPhone
« Reply #5 on: June 13, 2012, 04:31:31 AM »
Are you loading this with "Resources.Load" ?
Can attach a snapshot?

dex_scott

  • Guest
Re: Application.LoadLevel causing very strange behavior on the iPhone
« Reply #6 on: June 13, 2012, 04:43:45 AM »
Thanks for the reply.  Im using Application.LoadLevel to switch scenes when a button is touched.  It "toggles" between scenes.  Im also using this overlaid on a video camera surface and GPS, so not sure if that is part of the problem.  I make sure to stop those services before switching scenes.  Here is some code:

  1. void toggleButtonTouched()
  2. {
  3.         pauseGame();
  4.  
  5.         if (Application.loadedLevel == 1)
  6.         {
  7.                 Input.location.Stop();
  8.                 ((GPS)Camera.mainCamera.GetComponent("GPS")).enabled = false;
  9.                 ((MoveWithCompass)Camera.mainCamera.GetComponent("MoveWithCompass")).enabled = false;
  10.                 Application.LoadLevel(2);
  11.         }
  12.         else if (Application.loadedLevel == 2)
  13.         {
  14.                 Application.LoadLevel(1);
  15.         }
  16. }
  17.        
  18. void pauseGame()
  19. {
  20.         EtceteraBinding.showBezelActivityViewWithLabel("Loading...");
  21.         ((QCARBehaviour)GameObject.Find("ARCamera").GetComponent("QCARBehaviour")).enabled = false;
  22. }

joreldraw

  • Guest
Re: Application.LoadLevel causing very strange behavior on the iPhone
« Reply #7 on: June 13, 2012, 04:53:46 AM »
Nothing extrange there.

Test on editor withouth full screen and check hierachy when you loadlevel.

Is duplicated?

dex_scott

  • Guest
Re: Application.LoadLevel causing very strange behavior on the iPhone
« Reply #8 on: June 13, 2012, 07:37:44 PM »
Thanks for the reply.

I tried in the editor and noticed some objects being duplicated.  So I removed them, however it still has the same issues.  Im at a loss really...

dex_scott

  • Guest
Re: Application.LoadLevel causing very strange behavior on the iPhone
« Reply #9 on: June 13, 2012, 07:57:25 PM »
OK, Ive removed just about everything from the scene.  GPS/Camera/Facebook etc etc.  I literally just have an UIRoot object with a button and this single line of code:

  1. Application.LoadLevel(1);

The UI stays and flickers as the other scene is stacked on top.

Anyone have any idea?  Ive tried restarting Unity, updating NGUI, re-opening scene, enabling-disabling etc.  It works perfectly fine in the Unity editor but not on the phone.

dex_scott

  • Guest
Re: Application.LoadLevel causing very strange behavior on the iPhone
« Reply #10 on: June 13, 2012, 10:14:19 PM »
Changed my code to not use LoadLevel anymore.  Now I wrap every scene in a prefab and Destroy/Instantiate per this advice: http://forum.unity3d.com/threads/75635-Reloading-a-level-quickly..LoadLevel-too-slow

Same issue though...Maybe I need to start from scratch?  Have a deadline tomorrow, hopefully I can get this figured out!

joreldraw

  • Guest
Re: Application.LoadLevel causing very strange behavior on the iPhone
« Reply #11 on: June 14, 2012, 01:36:59 AM »
Try Loading async and waiting full loading...im using this without any problem on Android 2.1 and 3.1

IEnumerator Start() {
     AsyncOperation  async = Application.LoadLevelAsync(Level);
     yield return async;
       
    }


dex_scott

  • Guest
Re: Application.LoadLevel causing very strange behavior on the iPhone
« Reply #12 on: June 14, 2012, 02:05:51 AM »
Thanks for the reply.  I changed it to load asynchronously but I still have the same issue :(

PhilipC

  • Guest
Re: Application.LoadLevel causing very strange behavior on the iPhone
« Reply #13 on: June 14, 2012, 02:20:59 PM »
What version of Unity are you using? I just helped someone else who what having issues (not the same one) who was using 3.5.1 and upgrading to 3.5.2 solved his issue.

Rafe

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 78
    • View Profile
Re: Application.LoadLevel causing very strange behavior on the iPhone
« Reply #14 on: March 24, 2013, 09:48:17 PM »
Hi,

We are experiencing something similar. Only on iOS so far, not in the editor.

I am in Unity 4.1.0f4. I am fairly up-to-date on nGUI but am updating to v2.3.3h now.

When our main menu loads, the screen is empty. Then the title labels and buttons fly in from off-camera (title scale + position, buttons position only). When I don't use the Tweens, it works fine. When I do use the Tweens, the whole screen flickers. Even if I hit the play button through the flickering, the next level loads and the flickering continues. If the player dies chooses to quit to the main menu, everything starts looking right again.

I have the scene stripped down to just the UI root, panel, camera and a single button. I even tried a "loader" scene (built as the entry point and just has a little script to load the main title menu). We tried both LoadLevel and LoadLevelAsync with the same result. We are using NGui's LoadLevelOnClick component for the buttons (uses async I believe?)

My theory is it has something to do with geometry generation of camera, or large geo. I'm not sure. Even if the elements load on screen, and I use a co-routine to a wait a second and then activate the Tweens, it flickers once they activate.

Any idea what else I can try to debug this?

Cheers,