I’m trying to force the application to load a particular Scene “loading” whenever the player is started.
For this I use a static class like so:
[InitializeOnLoad]
public class Autorun
{
static Autorun()
{
String levelName = "loading";
Debug.Log("Autorun will load " + levelName);
Application.LoadLevel(levelName);
}
}
Unfortunately the Application.LoadLevel(levelName); seems to be completely ignored.
If this is to be expected I would like to know how I can achieve the Load at startup.
edit: The static constructor is executed at startup. I suspect Application is not ready when I call the LoadLevel
which would explain this behaviour. How should I proceed to run my code (save and preferences loading, network queries ad initial scene display) as soon as Application has finished initialising its dependencies?
Thanks.