Is there a level 1? Those numbers mean nothing until the build configuration is done and they have been indexed. You can also load a level by name with a string.
Make sure you build your game up with all levels included in the build, this code works for me:
using UnityEngine;
using System.Collections;
public class LevelMaster : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter(Collider other)
{
Debug.Log(other.gameObject.tag + " " + Application.loadedLevelName);
switch(Application.loadedLevelName)
{
case "Scene1":
Application.LoadLevel("Scene2");
break;
case "Scene2":
Application.LoadLevel("Scene1");
break;
}
}
}
However, my levels are called Scene1 and Scene2, replace that with the name of your levels, I used cubes as my level switch triggers.
In my current project I am communicating with MySQL by sending a WWWForm to a PHP script. After submitting the form I have no trouble loading levels.
How do you communicate with MySQL? Nothing as far as I know should stop a level from loading unless it causes the program to freeze, or maybe it is waiting/yielding for something?
I actually am using Connecter.NET (well something similar, no PHP files are needed, if you want to take a look PM me some way to get a hold of you, preferably AIM/MSN/etc)
if you do direct connects to DBs just keep in mind that you expose your whole db to any enduser cause the webplayer / standalone runs on their system not your website thus it needs wildcard accounts …