Hi there,
We, Apex Virtual Entertainment, have been working on a tool for Unity called ColdScene which we want to share with you guys and hear your feedback on it with any improvements that can be done or any bugs you might find. It is a tool which can save your Unity scenes to XML and load them in-game using asset bundles. Feel free to try it out.
The main reasons we started developing this tool were:
- We wanted a declared scene format
- We wanted to be more in control of scene loading and unloading
- We wanted to be able to do better memory profiling during scene loading (we haven’t been able to create a totally reliable memory profiler yet)
We have demonstrated ColdScene by using it together with our small prototype terrain engine called ColdTerrain (which is still in progress)
and another demo with two small simple scenes.
ColdScene (including the demos) can be downloaded here: http://www.apex.dk/technology/downloads/ColdScene_0.1.zip
Screenshots from the demos:
ColdScene - SceneXML v0.1 for Unity 3
Copyright 2010 Apex Virtual Entertainment
www.apex.dk
Created by:
Martin Schwartz
Apex Virtual Entertainment
martin@apex.dk
Last updated 22.11-2010
What is ColdScene?
A small tool to save any Unity scene to XML format.
These XML files can then be loaded (and unloaded) as
scenes in Unity as normal Unity scene files can.
Why ColdScene?
-
Load events
ColdScene will get pre and post event on loading
of all serialized properties and fields in the scene. -
Scene unload
Unloading scenes is possible in ColdScene which is
not currently available in Unity. -
Step-by-step scene load/unload for debugging
With the scene enumerator you are able to bit by bit
load (or unload) a scene bit by bit which can be handy
for debugging. -
Asynchronous scene loading problem solved
Using Unity’s own asynchronous scene loading have previous
caused problems for some and for Apex as well (this might
have been fixed in Unity 3.0 we haven’t tested that), so
we have tried to fix this with ColdScene. You also have the
option to choose how much time per frame you want to
use for the loading or unloading which is not currently
with Unity’s asynchronous scene load.
How do I install ColdScene?
Import the included unity package into your project.
The package includes a .dll file which must be in your
unity project, it includes some editor scripts to save
your scenes and it also includes some test
scripts/assets/scenes which are just demonstration of
how ColdScene works, which most of you probably want to
re-write yourself.
How does ColdScene work?
Saving:
Select the root of the scene you want to save. Click on
“ColdScene/Save scene to XML” to create the XML file.
An asset bundle will also be created that contains
all its dependencies and the XML file. It will be saved
in a subfolder of the Assets folder called “scenes”.
Synchronous loading:
Use: SceneManager.Get().LoadScene(string bucketId, float priority, string name)
(e.g. SceneManager.Get().LoadScene(“Root”, 0, “Root”), where “Root” is the
name of the asset bundle in the “ColdScene_files” folder, bucket is used as
an id for a tile where the scene is loaded so it is possible to prioritise
some tiles over other ones based on where the player is located, priority=0
will place requests in the front of the queue)
Asynchronous loading:
Use: SceneManager.Get().LoadSceneAsync(string bucketId, float priority, string name, double limit)
where ‘limit’ is a processing time duration in milliseconds per frame.
ColdScene loads/unloads tiny scene parts until it has used the ‘limit’ time duration.
Manual step loading:
First use:
ISceneEnumerator = SceneManager.Get().GetEnumerator(RequestType.Load, “Root”)
Then use for each step:
sceneEnumerator.MoveNext()
when sceneEnumerator.MoveNext() returns false the scene is fully loaded.
At every step a property is being set. If the component of the property
doesn’t exist the component will be created. If the game object of the
component doesn’t exist, it will also be created. The game object
will initially be deactivated and be activated
(if set to be so) when all properties have been set for the game object.
Remark
When building standalone apps remember to manually copy
the “ColdScene_files” folder containing the asset bundles of your
scenes into the data folder of the standalone build
(the subfolder of the build’s .exe file called “_data”).
Synchronous unloading:
Use SceneManager.Get().UnloadScene(string name)
Asynchronous unloading:
Use SceneManager.Get().UnloadSceneAsync(string name, double limit)
where ‘limit’ is a processing time duration in milliseconds per frame.
ColdScene loads/unloads tiny scene parts until it has used the ‘limit’ time duration.
Manual step unloading:
First use:
ISceneEnumerator = SceneManager.Get().GetEnumerator(RequestType.Unload, “Root”)
Then use for each step:
sceneEnumerator.MoveNext()
when sceneEnumerator.MoveNext() returns false the scene is fully unloaded.
A game object will be deactivated as soon as its first property is being set
to its default value (except for scene root objects which will remain
active at all time until deleted).
Can I obtain the source code of what is inside the .dll file?
Yes, you most likely can. Write an email to tech@apex.dk asking for it and
why you are interested in it, then we will get back to you.
Tutorial for loading/unloading test scenes:
- Open the ‘Start’ scene
- Run the player in editor (or in standalone build with ‘Start’ scene included)
- Click on ‘Load’
- Click on ‘Create player’
What is known to work (tested in 3.1.0f3):
- Game Object/Transform hierarchy
- Transform component data
- Textures references: Movie textures, 2d textures
- Quaternion fields
- Vector3, Vector2 fields
- Arrays
- Generic lists
- float, int, bool fields
- Color fields
- Rect fields
- Custom monobehaviour components
- Reference to other object/component
- Animation component and AnimationClip references
- Material references
- Mesh references
- Light components (except following properties: CookieSize,
ActuallyLightmapped, DrawHalo, Lightmapping, ShadowSamples
ShadowRadius, ShadowAngle, IndirectIntensity) - Audio source components and AudioClip references
- Prefab references (only reference to the root object at the moment)
- Terrain components and reference (except following properties: LightmapSize,
DrawTreesAndFoliage, CreateTreeColliders) - Asset dependencies between two different scenes
- Cloth components
- Audio reverb zone components
- Wind zone components
- Camera components (except: Flare Layer can’t be added)
- Remembers if game objects were inactive when saved
- Text Mesh (except following properties: OffsetZ, CharacterSize, LineSpacing,
Anchor, Alignment, TabSize) - Font references
- GUISkin references
What is known not to work:
- Layer masks
- Particle systems
- Doesnt work in Unity 2.x
Any kind of feedback is very much appreciated.
Thanks,
Martin Schwartz