- Home /
Loading/Unloading Content for very Large Scenes
We have a contract to create scenes that will be fairly complex, and segmented. We are loading all content from Asset Bundles, and placing content items in the scene based upon a data array. We are not using pure Unity Scenes for this, but are constructing the scene run-time per data arrays (where each line specifies: (a) Prefab FullName, (b) Position/Orientation/Scale, (c) Object Name).
We are wanting logic that will enable the loading/unloading of content and Levels-of-Detail based upon "regions" and "proximity". For example, we only want to load/show content of a room only when you enter that room (or approach the door that leads to that room). Also, for the outdoor portions of the scene, we will have proximity logic that only shows objects when you come within a specified distance threshold (radius based).
An outdoor example is this -- in one scene you might be driving a vehicle towards a village. While you are 2 miles away -- all you can see is a simplified low-detail model of the village. As you get closer (< 0.5 miles), this village will be replaced with individual building models, and as you get even closer, the smaller objects that populate the streets/alleys/courtyards will be loaded. If you enter a building, the content for that building will be loaded.
I hope you get the general idea. Our concept/solution/mindset is in flux right now. We are searching for an existing "headstart" on this solution (i.e. an existing project or code that solves this type of problem already).
Goals are:
Minimize amount of content loaded at any one time, to conserve on RAM and VRAM, and reduce the per-frame workload of the CPU and GPU (for drawing and culling).
Create a framework that enables the creation of larger world scenes where this content can be loaded/unloaded seamlessly based on proximity/region/trigger logic automatically.
Questions:
- Are there existing projects (or code) that are solving this problem already?
- Does anyone have educated recommendations for us regarding the approach we should consider?
We are willing to "create our own solution from scratch", but of course, would prefer to get a jump start by piggybacking an existing solution, if one exists and is willing to share.
Answer by cncguy · Aug 07, 2010 at 08:56 AM
I would suggest that you use colliders and OnTriggerEnter and OnTriggerExit. You can define a bounding area with a collider and when you enter you can have it trigger the download and instantiation of particular content. Once you exit the area you can trigger disposal of the content from the scene or downgrading to less computation intensive versions of the content. Once you have downloaded something once you would of course maintain a reference to it so that if you reenter the area you don't have to redownload those assets.
Your answer
![](https://koobas.hobune.stream/wayback/20220613070640im_/https://answers.unity.com/themes/thub/images/avi.jpg)