Unity3d: dynamically add and create scenarios, and unity3d scenarios

Source: Internet
Author: User

Unity3d: dynamically add and create scenarios, and unity3d scenarios
In Unity3d, most scenarios (scene) are implemented by clicking add current IN build settings or dragging the scenario to the Panel. If this is not done, Your scenarios will not be loaded, even if you have an absolute path.

That is to say, the number of scenarios to be loaded in a game is mostly fixed. Dog planing Learning Network]


This method may cause a lot of inconvenience and is not easy to dynamically load scenarios. So what we want to talk about today is a method for dynamic loading scenarios.


First, you need an editor file in the editor folder. Note: This file cannot be inherited from monobehaviour


  1. Public class BuildSceneEditor {[@ MenuItem ("build/BuildWebplayerStreamed")] static void Build () {string [] levels = new string [] {"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. If you execute this button, the created streamed will appear in the directory of your Assets at the same level. unity3d file, you put this file on the server, the next step is to download this file and build it.


  1. WWW download = WWW. LoadFromCacheOrDownload ("http: // xxx/streamed. unity3d", 0); yield return download; Application. LoadLevel ("Level1 ");
Copy code

Have you noticed this. After downloading, you can directly loadlevel without manually performing the add current operation.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.