Weird LoadLevel Error

Hello,

EDIT the language is c#

I’ve been getting random errors whenever I try to do normal unity operations such as loadnig a level, the sendmessage command, etc. I have fixed all the other errors but i do not know how to get around this one.

Basically its just the red error message with this text:
UnityEngine.Application:LoadLevelAsync(String, Int32, Boolean, Boolean)
UnityEngine.Application:LoadLevel(String) (at C:\BuildAgent\work\6bc5f79e0a4296d6\Runtime\ExportGenerated\Editor\BaseClass.cs:1492)

Thats it. I am using loadlevel, not loadlevelasync. The line of code is this:

Application.LoadLevel(“CharacterSelectionScreen”)

That’s a correct name of the scene; but this error.

Please help :slight_smile:

Thanks,
Christian

I had this same issue. I fixed it by adding a boolean that was checked in my update function so it was the first thing that ran in my next frame.

private void someFunction()
{
   // Bla bla bla
   loadLevel = true
}

void Update()
{
   if (loadLevel)
   {
      locadLevel = false;
      Application.LoadLevel(2);
   }
}

I searched for hours trying to figure out why it wouldn’t load but others said that it is ran at the end of the frame? Its a work around but it works. Also not sure if you were trying to run it from a static function but that could have done it to.

Basically it HAS to be in 1 of the Unity functions.