- Home /
Create scenes at runtime
EDIT: The question was based on an misunderstading of how scenes work. I will have to seralize runtime-changes by myself as it seems.
Hello,
the title explains it already. I want to create scenes at runtime and load them right after, though I haven't found the functionality for it. It seems Unity needs to know all its scenes when it gets built. The problem is that I want to make a map generator and one should be able to generate as much worlds as he likes. Creating scenes would come in handy for that purpose.
Otherwise it seems that I would have to serialize all my worlds and everytime the player changes the world, unserialize it and load it into a default empty scene, but frankly I don't like this idea.
Can anyone help?
Answer by CoixdeNono · Feb 13, 2013 at 03:44 PM
Try to add the scenes to the build settings at runtime. I found this ( http://answers.unity3d.com/questions/10482/accessing-buildsettings-from-buildsettingsasset.html ) dont know if it helps : var original = EditorBuildSettings.scenes; var newSettings = new EditorBuildSettingsScene[original.Length + 1]; System.Array.Copy(original, newSettings, original.Length); var sceneToAdd = new EditorBuildSettingsScene("Assets/Path/To/Scene/sceneName.unity", false); newSettings[newSettings.Length - 1] = sceneToAdd; EditorBuildSettings.scenes = newSettings;
Thank you for your answer, but this doesn't help me as EditorBuildSettings is an Editor class and respectively cannot be accessed at runtime.
Answer by Yasantha · Feb 13, 2013 at 04:00 PM
what if you make Empty Scene with out anything. and load that scene after that load Ur prefabs trees as Assets dynamically. (Recourses.Load() )
Yes i can do that, thank for your help. But i'm trying to understant all the features of the AssetBundle. And i did, except for the download and import of a scene.
Exactly that's what I want to do. But then I want to save that scene and create another, that is the actual problem. To have the possibility of theoretically infinite scenes, which I currently don't see in Unity.
Your answer
Follow this Question
Related Questions
How can I dynamically create scene ? 1 Answer
Display Raw Images at runtime in unity 4.6 0 Answers
Create a plane from points 1 Answer
How to create a Script from another Script on runtime 1 Answer
Can I create Scene via script? 2 Answers