- Home /
Manual loading scene inside editor
For loading scene inside editor I use this function:
Resources.LoadAssetAtPath("Assets/Scenes/myscene.unity", typeof(Object));
It returns me instance of UnityEngine.DefaultAsset
Then I try load "myscene" using this function:
Application.LoadLevel("myscene");
But it says that Level 'myscene' (-1) couldn't be loaded because it has not been added to the build settings.
I don't want to add it to build settings, because in web player I load it using bundles. And inside editor I want to load it directly. How can I do it?
Why do you need a script to change scene in the editor? Just double click a scene and it will load.
@$$anonymous$$hada, this can be needed for some batch operations for example.
I want to make code that will have different behavior in editor and in web player. In Web player I loaded scenes from bundles, in editor I want loaded it directly. But if I add scene to build settings, and I can't make build, because unity include that scene in unity3d files. So I always need to add and to remove scenes from build settings, that was problem.
Answer by raimon.massanet · May 14, 2013 at 12:57 PM
I think you are looking for this:
http://docs.unity3d.com/Documentation/ScriptReference/EditorApplication.OpenScene.html
Answer by ScroodgeM · Aug 23, 2012 at 06:57 PM
edit
create a simple 'if' block with this check and load scene directly or using bundle. you can't write in one line a code that will load asset bundle packed scene in unity web player or directly using editor's methods if you are in editor.
also you can use #IF blocks to exclude editor-loading lines from web player build
Thank you, but I need to make it in editor play mode and using in game script. As I wrote in post above. I need the same behavior in editor play mode as in web player mode.
Answer by Mander · Aug 23, 2012 at 07:57 PM
with ur scene open. go to Files->BuildSettings then clic the Add Current button. and u r set to go
I don't want to add it to build settings, because in web player I load it using bundles. And inside editor I want to load it directly.
Your answer
Follow this Question
Related Questions
heavy scene loading 1 Answer
Building single scene is much too large! 0 Answers
pre-load multiple scenes but only activate one 0 Answers
Addressable for Oculus Go 2 Answers
How to determine which resources are loaded while loading scene 1 Answer