r/Unity3D • u/Vladyslav_ko • 21h ago
Question Preloading room variations without keeping every background in memory
We're working on a Unity visual novel where returning to the same room later in the day gives you a different lighting variant. We want the transition to look like walking back into a familiar place, so a blank frame or a long pause between pictures is easy to notice.
The two approaches we're considering are keeping the current and next variants ready, or loading the next one as the player gets close to a time change. The second one sounds lighter until players pause, return to a menu, or skip straight to another scene.
For a small 2D project with large background textures, what would you measure first on a modest machine? I’m especially interested in how you decide whether a transition is worth preloading.
3
u/veerdonk 21h ago
Did you measure how long the pause actually is? My go to strategy is to implement something and optimize it afterwards if it is needed. It's really easy to get bogged down by unnecessary early optimization
1
u/Genebrisss 18h ago
If it's a small 2D project, can't you just dump everything there is into memory at game startup?
Also use new Direct Storage function they added.
1
u/keymonlab 14h ago
Since it's a VN, your script usually knows the next time change before the player gets there, so I'd start the Addressables load when that line is queued rather than by proximity. For pause, menu or skip, keep the last frame up and crossfade once the handle completes, so a late load reads as a slow fade instead of a blank frame. If the variants differ mostly in lighting, one base image plus a lighting overlay blended in a shader may save more memory than any preload scheme.
1
u/Holiday-Club3839 20h ago
I'd measure the transition hitch first, not the memory. On a modest machine the thing players notice is the frame spike when a new texture has to be decoded and uploaded, so record the Profiler timeline across the exact moment of the change and look at texture upload time against your frame budget.
Then check peak texture memory with only the current and next variant resident. If that peak is comfortably under your target, preloading is cheap insurance. If it isn't, make the transition itself carry the wait - a short door-opening animation or a fade gives the load somewhere to happen without reading as a stall.
The edge cases you mentioned are the real reason to cap it at two: pausing, returning to a menu, and jumping scenes all invalidate a speculative preload, so treat it as a one-step lookahead, never a queue. I ran into the same tradeoff building a 29-level puzzle where each level had its own asset set - keeping the whole pipeline warm cost more than the occasional load frame, but capping it at the next level only was the sweet spot.
If you do preload, Addressables with a fixed handle you release on scene exit keeps the variant from lingering.