Course contentsShow
← Unity Game Development
Lesson 29 of 8281. Unity FoundationsFree lesson

Applying Static Flags for Scene Optimization

Identify and mark static objects within your hierarchy to allow the engine to precompute lighting and navigation data efficiently.

In this lesson, you will learn how to identify and mark objects as "Static" to help Unity precompute complex data for your scene.

Understanding Static Objects

In Unity, most objects are "dynamic," meaning they can move, rotate, or change size while the game is running. Because they move, the engine has to calculate how light hits them and how AI navigates around them every single frame. This consumes a lot of processing power.

However, many objects in your scene—like walls, floors, or large boulders—never move. By telling Unity these objects are Static, the engine can perform heavy calculations just once while the scene loads, rather than calculating them over and over during gameplay.

Applying Static Flags

To mark an object as static, follow these steps:

  1. Select the GameObject in the Hierarchy.
  2. Look at the top-right corner of the Inspector window.
  3. You will see a dropdown menu labeled Static.

By default, this is unchecked. When you check the box, every sub-option (like Lightmap Static, Navigation Static, or Occluder Static) is enabled. This tells Unity: "This object will never change its position, rotation, or scale."

Why It Matters

When you mark an object as Lightmap Static, Unity pre-calculates the shadows and light bounces onto that object's texture. When you mark it as Navigation Static, Unity calculates the "navmesh" (the paths AI characters can walk on) based on that object's footprint before the game even starts.

If you leave these objects dynamic, the engine wastes resources constantly checking if a static wall has moved. By checking that box, you free up the processor to handle more important tasks, like physics or game logic.

If you ever decide to move a static object via a script during gameplay, Unity will issue a warning because you are changing an object that promised to stay still. Always remember: if it doesn't move, make it static!

Key Takeaway: Marking GameObjects as Static signals to Unity that they will never move, allowing the engine to precompute lighting and navigation data for a significant performance boost.