I’m trying to set up a system to play some in-game cutscenes within my game. They will play only once on a play-through.
The way I have things set up right now, I have code that gets called at the very start of certain levels. One of the first thing it does is check if certain events have occurred, in this case, if these cutscenes have played. If not, it starts the cutscene (which currently is just a placeholder text box) and if so it just does nothing.
Right now I’m setting up my scripts to actually perform the cutscene, and there is an issue I am running into.
When the cutscene actually performs, it is going to display a number of graphics and things that are only used for this event. If/when the player ever returns to this level, the cuscene won’t play, and thus all those special graphics and other assets won’t be needed.
While I could have all those various assets sitting in my scene, ready to be used, this will cause the level to take longer to load if/when the player returns to the level. It seems to me that it would be wiser to NOT load those various assets, and if the initial script determines that the cutscene needs to play, THEN it loads all those extra assets and plays the cutscene.
I am wondering the best way to go about this.
(Or what effective methods are possible, really.)
At first my thought was to tie in these assets with a prefab, and then I can have a reference in my script to all these assets that it can import into the scene just when it is called for. But would that actually work? Or when I have an object in my scene with a public variable referencing that prefab, will the scene automatically load that prefab when the scene loads, thus defeating my plan to avoid loading it?
And as I think about it, right now these cutscenes consist of just large images to use like splash screens, but as my game develops these will be replaced with more complex entities. They may come to contain more data than I would feel comfortable putting into a single prefab. I’d like to use a system that can work with calling all the data I need when I need it.
I know there is the Resources folder that I can put assets into that I can call via scripts, but I am concerned about putting too much into that folder. Do the contents of that folder create any extra overhead in my game? It doesn’t sound reasonable to put things in that folder that are only ever used once.
The only other thought I have is to stream in multiple scenes, so I could put all of the extra assets into a separate scene and then load it just when I need it. Now it’s been a while since I’ve looked into that, but I remember that used to be functionality locked behind the paid version of Unity. Has that changed? Can I stream multiple scenes into my game with just the basic version of Unity?
Also, all this has gotten me to wonder what kind of memory costs these (and other parts) are adding to my game. I’m wondering about memory management in general; how I can monitor how much memory my game is using, how I can control the loading/unloading of various assets to keep the memory requirements down, if it comes to it. I suppose its a different subject altogether, but it seems like something I would want to keep in mind.
But at any rate, what are some effective ways I can structure my system for loading assets so that I don’t have to load a bunch of things I won’t need every time my level loads?