I basically want to duplicate the functionality of OnLevelWasLoaded(int level) but for these functions:
Application.LoadLevelAsync
In cases like this I use a LevelLoader which has events that get called. You declare your own events and then call them before and after the load event.
public delegate void LevelWillBeLoaded();
public delegate void LevelWasLoaded();
public static event LevelWillBeLoaded OnLevelWillBeLoaded;
public static event LevelWasLoaded OnLevelWasLoaded;
public void LoadLevel(string levelToLoad)
{
StartCoroutine(LoadLevelCoroutine(levelToLoad));
}
IEnumerator LoadLevelCoroutine(string levelToLoad)
{
if (OnLevelWillBeLoaded != null)
OnLevelWillBeLoaded();
yield Application.LoadLevelAsync(levelToLoad);
if (OnLevelWasLoaded != null)
OnLevelWasLoaded();
}