I am working on a project which contains four scenes the user moves from the first scene to one of the three others and back again, this is probably explained best with a picture:
Scene 1 and 2 contain a large shared asset (Several Meshes, 44MB at the moment but totally unoptimized) Scene 3 and 4 do not contain any shared assets. When exported to the web player moving between Scene 1 and Scene 2 is rapid there is a slight perceptible pause but not enough to even be able to read the word "Loading" on my loading screen.
However when moving from Scene 4 to Scene 1 or Scene 3 to Scene 1 (Red Arrows) there is a long pause. My first thought was to put the asset in Scene 3 and 4 which works but feels dirty. I also create a script which I could attach to the asset using DontDestroyOnLoad(this) this removed the delay but caused the asset to be duplicated on each subsequent load.
I have seen several scripts which apply DontDestroyOnLoad then Destroy(GameObject) the asset manually. This also feels quite dirty.
Is there a better way of keeping a large asset in memory and prevent an object from being instantiated multiple times.
asked Oct 24 '10 at 08:07 PM
Here is one way to solve the persistence / duplication problem:
I don't know whether this is cleaner than any other method, but it's worth considering (we usually use for our "logic" objects, not meshes).