Smooth Scene Streaming with Unity3D

Smooth Scene Streaming with Unity3D

Tech StudyGame Project
Jun 11, 2022

Introduction

I am Dimitar from The Sixth Hammer - a small independent Bulgarian game studio, currently focused on 2D game development using the Unity3D engine. Our largest game - Moo Lander, required us to find creative solutions to a lot of difficult problems, typically arising in more complex games. We wanted Moo Lander not to include loading screens and instead be one big open 2D world. So we needed to find a solution to the problem of performantly streaming content during gameplay.

In Unity we have the concept of Scenes, so we just needed to find a way to load those in the background while the gamers play the game. Simple enough, right? Wrong!

  1. How to know when to unload a scene e.g. when even distant background objects are not visible and nothing from the scene is needed anymore?
  2. How to keep track of which scenes need to be loaded when multiple players can be in different places in the game world?
  3. How to load/unload scenes in the background without any spikes in performance?

These are some of the questions I will try to answer in this article. Come on, let’s dive deep into the topic!

The Current Out-Of-the-Box Features Unity Offers

You can imagine the Scenes in Unity as "bundles" of Game objects. Unity offers two types of loading a scene - Additively and Non-Additively. Non-additive loading replaces the current scenes with the loaded one, while additive loading keeps the already loaded scenes - in our case we needed additive loading.

Unity also offers two ways of loading each of the types - Synchronously (that basically pauses everything else until the loading is done) and Asynchronously (in the background). For our game - Additive Asynchronous loading was the type we used.

Our Solution

We’ve had to build a whole system of game objects and helper classes for the scene loading in order to tackle the aforementioned issues that arose during development.

Smooth Scene Streaming with Unity3D

Scene Switchers

We thought long on what is the best solution for loading/unloading a scene at the right moment (when the action is minimal, when the scene itself is not visible and when the scene is not needed anymore anywhere else). In the end, we came up with the idea of a Scene Switcher.

Each Scene Switcher holds as children two "Gate" Game Objects. Each of those has a 2D physical trigger collider (that is usually rectangular, but may be shaped in any way if needed to fit a scene layout). The Scene Switchers also have a field for the Scene Name, that it needs to load/unload. It then keeps track of the interaction with its Gates. An interaction with a player in the way of 1 => 2 should load the scene, while interaction of 2 => 1 should unload the scene.

The white rectangles with tiny "1" and "2" texts on them are Scene Switchers:

Smooth Scene Streaming with Unity3D

Scene System

Scene Switchers may know a player’s intention to load or unload a scene. But we’ve separated the actual process of loading a scene to another singleton system class, that keeps track of all of the player’s intentions as well as which scenes are already loaded.

It does that by doing a few things:

  1. It keeps a Dictionary with the Needed Scenes where the Scene Name is the key, and a List of players that need that scene is the value. It then provides a method UpdateGameObjectNeededScenes(GameObject GO, string sceneName, bool shouldLoad) for updating the dictionary.
  2. It keeps a Dictionary with the currently Loaded Scenes (Scene Name as a key, Loading State as a value) that it keeps up to date by subscribing to the Unity’s built-in Scene management events.
  3. It runs a function in the game’s Update loop, that checks if the loaded scenes and the currently needed scenes match, and if not, it initiates load/unload of scenes.

Of course, the actual implementation includes a dozen of helper functions and other variables, but this is the main idea. With that architecture, we are solving the first two issues (mentioned at the beginning of the article) gracefully.

On the other hand, the third issue about the performance deserves a separate page of its own. So let’s see what were the issues and challenges there and how we solved them.

Improving Additive Loading Performance

The way Unity loads a scene in the background works pretty well while the scene is loading. But then on the last frame Unity creates and activates all of its game objects (which is normal behavior, because the engine cannot know the dependencies between them) which causes a pretty substantial lag.

The severity of the lag mostly depends on two things:

  1. The count of the Game objects in a scene with their respective used assets and resources counts.
  2. The count of MonoBehaviour components, attached to them (especially valid if they have logic that executes in the Awake or Start methods)

So based on that, we have a couple of different approaches to improve the performance:

  1. We can make our Scenes smaller e.g. reduce the count of game objects in them. That could improve performance but will make our game management much harder with more frequent Scene Switchers and loadings happening throughout the whole game.
  2. We can reduce the MonoBehaviours count, which is a valid approach to improving the performance. But in our case, it was simply not possible, because of the complex behaviors that most of the game objects have in Moo Lander.
  3. We found a way to somehow not activate all game objects in the scene simultaneously - this was the best approach for us because we did not have to cut complexity that way and achieved a tremendous performance boost.

Smooth Scene Streaming with Unity3D

Delayed Activation of Game Objects

In order to do that, we first need to prevent Unity from doing this automatically on scene load. Unfortunately, we did not have a built-in way to do that, so we just went ahead and:

  • Parented all of our scene game objects to a single Scene game object.
  • Moved all of our physical interactable game objects into an Interactables game object that is a direct child of the Scene game object.
  • Wrote a tool that disables all of the Scene game objects when making game builds. That way when unity loads a scene, it is loaded in a disabled state.

We then extended the scene system that was responsible for the loading/unloading of our scenes with the following behavior for after a scene is loaded:

  1. It first checks if the loaded scene has the disabled Scene object at the top.
  2. If it has one, then it means that we want to do a delayed activation of the child game objects, so it loops all of the multi-level children and disables them one by one.
  3. It enables back the parent Scene object. At this point, nothing is still visible, because all of the children are now disabled.
  4. It starts a coroutine that loops all of the children and activates a certain amount of them each frame. A very important note is that this coroutine must skip the Interactables holder - this is because if we enable physics objects over time, we could potentially have a broken behavior (like enabling an enemy before the ground below will make the enemy fall through).
  5. It then enables all of the Interactables game objects at once (which still causes a small performance lag, but this is orders of magnitude smaller because we are enabling only tens instead of thousands of objects like in the beginning)

With that, we improve the quality of the player experience by removing the nasty performance spikes when additively and asynchronously loading scenes with Unity.

Smooth Scene Streaming with Unity3D

Bonus tip - unloading a scene does not actually unload all of the used textures and other assets that the scene uses. This is why you should also call the built-in UnloadUnusedAssets method from time to time during gameplay in moments where there is not much action. That causes a small spike in performance. But We still have not gotten to the point, where we would need to optimize that Unity behavior.

Also, check out this link for other insights on improving the async loading of scenes.

Conclusion

As you see, there is a lot happening in order to ensure the smooth loading of everything the players need throughout a game. And after we finish with Moo Lander, we will package all of that into a plugin that would save a lot of time for future fellow developers.

Of course, there is much more happening to our game scenes and objects (like persistent objects that can move between scenes, etc..), but I will share insights on that with you in future articles. For now, I hope this will give you enough of a direction to build your own great solutions to the additive scene loading problem.

 

decorative dotsFrom Blog
Lectures in University of Veliko Turnovo "St Cyril and St. Methodius"
Event
Dec 11, 2025
Lectures in University of Veliko Turnovo "St Cyril and St. Methodius"

The Sixth Hammer’s Level designer, Alexander Filipov, ran a course of lectures on game design in University of Veliko Turnovo "St Cyril and St. Methodius".

Lectures in University of Plovdiv "Paisii Hilendarski"
Event
May 05, 2025
Lectures in University of Plovdiv "Paisii Hilendarski"

Dimitar Popov, one of The Sixth Hammer co-founders, was invited by University professors to give guest lectures on game design and Unity programming.

The Sixth Hammer at CreaTech Summit South-East Europe 2025
Event
Apr 06, 2025
The Sixth Hammer at CreaTech Summit South-East Europe 2025

Industry experts, policymakers, cluster organisations and creators from Eastern Europe gathered in Sofia for CreaTech Summit South-East Europe to discuss the future of creative media.

The Sixth Hammer at MWC Barcelona 2025
Event
Mar 25, 2025
The Sixth Hammer at MWC Barcelona 2025

The co-founders visited Spain for a series of business meetings. While in Barcelona, they attended Mobile World Congress Barcelona 2025.

KoSher 2024
Event
Sep 20, 2024
KoSher 2024

Yasen Bagalev, one of the Sixth Hammer’s cofounders, Sofia Game Jam’s Filip Tarpov, and Hardcore Game Jam’s Angel Marchev ran a panel discussion at KoSher 2024 in Sofia.

The Sixth Hammer at Plovdiv Game Jam 2024
Event
Feb 06, 2024
The Sixth Hammer at Plovdiv Game Jam 2024

Plovdiv Game Jam is one of the biggest gaming events in Bulgaria as part of the Global Game Jam. Members of The Sixth Hammer held talks and helped organize the event.

Inspiring Industry Insights: 2022 GIC Poznan
Event
Nov 05, 2022
Inspiring Industry Insights: 2022 GIC Poznan

Yasen Bagalev and Dimitar Popov held a talk on "The impact of music and SFX in immersive games" at GIC 2022 in Poznan, Poland.

The Sixth Hammer takes Gamescom 2022 by storm with Moo Lander
EventGame Project
Sep 10, 2022
The Sixth Hammer takes Gamescom 2022 by storm with Moo Lander

Among the participants in Gamescom 2022 is the indie game studio The Sixth Hammer, ready to make their mark with their highly anticipated game, Moo Lander.

Moo Ball Tournament at Cooldown
EventGame Project
Aug 10, 2022
Moo Ball Tournament at Cooldown

The Sixth Hammer held a Moo Ball football tournament in Cooldown - a one-of-a-kind gaming pub in Plovdiv.

Smooth Scene Streaming with Unity3D
Tech StudyGame Project
Jun 11, 2022
Smooth Scene Streaming with Unity3D

Technical article with tips and tricks on how to design and optimize a big seamless 2D world without loading screens in Unity.

Moo Lander’s Mooltiplayer
Game Project
Apr 25, 2022
Moo Lander’s Mooltiplayer

What’s a fun game without a family friendly competition? Moo Lander has its own couch co-op Mooltiplayer, supporting up to four players on PlayStation 4, Xbox One and PC.

Achieving Optimized Depth-Of-Field effect in a 2D Unity Game
Tech StudyGame Project
Feb 17, 2022
Achieving Optimized Depth-Of-Field effect in a 2D Unity Game

Technical analysis on the best way to implement Depth of Field for a 2D game with semi-transparent Sprites using Unity.

Moo Lander short documentary is out now!
Game Project
Aug 08, 2021
Moo Lander short documentary is out now!

Join the developers and learn more about Moo Lander - the upcoming action adventure game where you fight mighty cows and solve ancient puzzles.

BEGE Expo 2017
Event
Nov 13, 2019
BEGE Expo 2017

The Balkan Entertainment & Gaming Expo is one of the biggest conference and exhibitions in Eastern Europe and The Sixth Hammer had a booth to showcase Moo Lander.

Startup Weekend Plovdiv 2017
Event
Mar 28, 2017
Startup Weekend Plovdiv 2017

The Sixth Hammer presented Moo Lander’s first prototype at Startup Weekend Plovdiv 2017. The event gathered entrepreneurs from the region and hosted networking sessions.

infiniaContact us

Let’s talk about your project

infinia
Email Us Directly
Email Us Directly

Reach out to us and schedule a meeting to discuss your development needs.

Let’s Collaborate
Let’s Collaborate

We work with studios, publishers, brands and agencies. We do full-cycle development or co-dev.

Working Worldwide
Working Worldwide

We’re operating globally - we can sync with your working schedule wherever you are.