A system for Subscenes in Unity that mimics Unity's ECS SubScenes, without using the Entity Component System. Not compatible with the Entities package. I made this because I wanted the organizational benefits Unity's SubScene system brought without having to convert my current project to ECS.
First, make sure that the SubSceneEditor script is located in your Editor folder. More information can be found here.
You can create a new Subscene using the following static methods:
SubScene.CreateEmptySubscene();
SubScene.CreateSubsceneFromGameobject();
SubScene.CreateSubsceneFromGameobjects();
You can also right click on GameObjects in the Hierarchy of an existing Scene, and select the Menu Option:
- New Subscene From Selection
Opening and closing the SubScenes is simple.
SubScene subScene;
subScene.OpenSubscene();
subScene.CloseSubscene(saveFlag);
Please remember that scene loading is Asynchronous, and read the comments on these methods for more information.
- There's currently a reflection issue causing an error to be logged to the Unity Console. It doesn't seem to cause any other issues.
- Sometimes, saving a Scene with an active SubScene prompts a Unity Editor Error Message claiming that the Scene was unable to be saved. Clicking "Try Again" or "Cancel" successfully saves the Scene.
- Nested SubScenes are not currently tested and not supported (at least insofar as the editor scripting portion is concerned).
For drawing the Tree Structure, I referenced Pretty Hierarchy, StackOverflow, and the Unity Forums.