functon is not valid here.
Assuming this is a cut and paste error, make sure of the following things:
- you have at least two scenes in the build settings
- it works in the editor (load scene 0 into the editor and press the play button)
- you added your script to the object in scene '0'
In addition, I suggest using scene names instead of the scene index when calling Application.LoadLevel .
For example, you might have a scene called "Preboot" and another one called "Menu." Your "Preload" scene will be the first in your build settings. Then the call will be as follows:
Application.LoadLevel("Menu");
This is less error prone if you reorganize the order of the scenes in the build settings, especially after your project starts to grow.
source share