- Home /
LoadLevel while FB.Init is in progress
I have a bootstrap scene containing a single GameObject which holds the initialization script, just after all variables are initialized I'm calling Application.LoadLevel to load the start screen. This is the Awake function:
void Awake(){
DontDestroyOnLoad(gameObject);
FBReady = false;
FBStarting = true;
try{
FB.Init(FBInit);
}catch{
FBStarting = false;
}
Application.LoadLevel("Splash");
}
void FBInit(){
FBStarting = false;
FBReady = true;
}
Since the GameObject is not destroyed upon scene load, is natural to assume that all its properties, status data, coroutines, pending operations, etc, will also survive, but apparently this is not what really happens. FBInit is never call unless I comment Application.LoadLevel("Splash");. So obviously there are things that do not survive a scene load when you instruct Unity to DontDestroyOnLoad an object.
In my specific case the solution to this problem is quite simple, you just call LoadLevelAdditive instead of LoadLevel, and everyting works just fine... however what happens in a similar situation when LoadLevelAdditive is not an option?, how do you work around it?
Answer by zzzzzz789 · Sep 26, 2015 at 09:52 AM
You could try to spin on the FB.IsInitialized bool with a timeout.