- Home /
First scene of Unity project larger than what would be expected.
I'm creating a Unity2D game targeting the web and so I want streaming to work smoothly. I created a tiny scene with just a monochrome logo and loading bar. The image assets are around 500 bytes in total, but when I build, the first scene takes up 0.9mb compressed while the next scene which has significantly more assets only takes up 0.2mb. Because of this, the webplayer stays on the unity loading screen for a long time and only displays my tiny loading screen for a second before going into the game.
I assume that this must have something to do with the fact that I use a static class to manage my Audio so when the game starts up, it loads all the static stuff which forces the first scene to include the audio files. The code that actually loads the audio isn't called until later when the player starts the game.
private AudioSource aSource;
private AudioSource audioSource{
get{
if(aSource == null){
aSource = gameObject.AddComponent<AudioSource>();
aSource.clip = Resources.Load("Progenibeat") as AudioClip;
aSource.loop = true;
DontDestroyOnLoad (aSource);
}
return aSource;
}
}
Is there any way to structure how audio is handled so unity knows it doesn't need to load the audio files until later in the game.
It is also possible that there is some other reason the first scene is always larger, but there doesn't seem to be a way to check which files are loaded for each scene.
Many Thanks!