Unusual problem loading a scene.

I have a simple test project with two scenes, a title scene and a game scene. The script shown works perfectly when used with the title scene and it loads the game scene with the 3 second delay.

If I use this same script in my other main project in the same way it will not work WITH THE INVOKE FUNCTION. I have a few scenes in that project and it will not load any, but IF I COMMENT OUT THE INVOKE FUNCTION it will load any scene.

I have also tried the yield WaitForSeconds function too, this does the same thing, working in one project but not the other.

There are no errors showing in the console. When the button is pressed in the menu scene it just stays at the menu scene. The scenes have been added to the build settings box. I’ve also tried making another simple menu and game scene in the main project and even these don’t work with the delay functions.

Why should the same script with an invoke function work in one project but not another?

I’ve loaded the lastest Unity update but it didn’t make any difference.

var customSkin:GUISkin;

function OnGUI () {
    if(GUI.Button(Rect(0,0,100,35),"Play Game")){
       Invoke("WaitAndLoad", 3.0 );
function WaitAndLoad(){
    Application.LoadLevel ("Test Game");

Application.LoadLevel destroys any non “DontDestroy” game objects on the current scene (as you are not calling LoadLevelAdditive). I don’t use UnityScript, but my guess is that Invoke exposes some timing issue where the MonoBehaviour that is doing the invoking is destroyed somehow? Just a guess. Make sure that if you are not doing additive scene loading that the thing you are loading from is marked DontDestroyOnLoad. I have seen this cause some strange, unpredictable behavior before.