In Unity3d, the scene is mostly done by clicking Add Current in the build settings or by dragging the scene into the panel, and if you don't, your scene will not be loaded, even if you make an absolute path.
that is, the number of scenes to be loaded in a game is mostly fixed. " Dog planing Learning net "
Such a method will have a lot of inconvenience, not easy to dynamically load the scene. So what we're going to say today is a way to load the scene dynamically.
First, you need an editor file, placed under the editor folder. Note that this file cannot be inherited from Monobehaviour
- public class buildsceneeditor{[@MenuItem ("build/buildwebplayerstreamed")] static void Build () {string[] levels = new STR ing[]{"Assets/level1.unity", "assets/level2.unity"}; Buildpipeline.buildstreamedsceneassetbundle (Levels, "Streamed.unity3d", Buildtarget.webplayer); } }
Copy Code
In this way, a button appears in your Unity editor, you execute this button, you will appear in your assets sibling directory in your build good Streamed.unity3d file, you put the file on the server, the next step is to download the file and build.
- WWW download = WWW.LoadFromCacheOrDownload ("Http://xxx/streamed.unity3d", 0); yield return download; Application.loadlevel ("Level1");
Copy Code
have you noticed that? Download good after you can directly loadlevel, do not need to manually add current operation.
Dynamic increment and build scene in Unity3d