You can do that at editor time using things like [InitializeOnLoad][1]. Not sure if you can do that at runtime.. It needs somehow to get triggered by an instance on the scene. You could use [PostProcessSceneAttribute][2] to create an object before the scene gets built.
[1]: http://docs.unity3d.com/Manual/RunningEditorCodeOnLaunch.html
[2]: http://docs.unity3d.com/ScriptReference/Callbacks.PostProcessSceneAttribute.html
↧