CodeBlanks Logo Icon CodeBlanks

Build Settings in depth

Learn the platform and scene settings of Build Settings.

Build Settings and the scene list

The game building process in Unity is managed from the File > Build Settings window. The Scenes In Build list specifies the scenes included in the final game and their respective build indices.

// Scene with index 0 is the initial scene loaded on launch
int totalScenes = SceneManager.sceneCountInBuildSettings;
SceneManager.LoadScene(0);

Scenes omitted from this list are excluded from the output build and cannot be loaded via script.

Switching platforms and Development Build

To target a different operating system, click the Switch Platform button at the bottom left. This re-imports textures and audio into the target platform's formats.

// Debug logs stay active when Development Build is enabled
#if DEVELOPMENT_BUILD
Debug.Log("Development build is active");
#endif

During testing, Development Build and Autoconnect Profiler flags are checked for profiling support.

Practice Print first scene and scene count

Print the first scene (Index 0) and the total number of scenes (scenes.Length) formatted as "Ilk: GirisSahnesi | Toplam: 3" using Console.WriteLine.

Starter code

Player.cs
using System;

class SceneBuildList
{
    static void Main()
    {
        string[] scenes = { "GirisSahnesi", "Bolum1", "Bolum2" };
        // Ilk sahneyi (Index 0) ve toplam sahne sayisini konsola yazdir
        
    }
}

Sample solution

Player.cs
using System;

class SceneBuildList
{
    static void Main()
    {
        string[] scenes = { "GirisSahnesi", "Bolum1", "Bolum2" };
        Console.WriteLine($"Ilk: {scenes[0]} | Toplam: {scenes.Length}");
    }
}

Expected output

Ilk: GirisSahnesi | Toplam: 3

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 What is the key characteristic of the scene at Index 0 in the 'Scenes In Build' list?

  • It is a persistent UI scene that can never be unloaded from memory
  • It is a developer test scene that runs only in editor play mode
  • It is the initial scene automatically loaded when the game launches Correct answer
  • It is the scene that was last saved and modified in the project

Explanation: The scene situated at Index 0 is the entry scene automatically opened by the engine when the standalone game starts.

2 Get build scene count

Question
int sceneCount = UnityEngine.SceneManagement.SceneManager.____;
Answer
int sceneCount = UnityEngine.SceneManagement.SceneManager.sceneCountInBuildSettings;

Explanation: SceneManager.sceneCountInBuildSettings returns the number of scenes added to the Build Settings list.

3 Build Settings concepts

Term Meaning
Scenes In Build List of scenes included in build
Index 0 First scene loaded when game starts
Switch Platform Re-imports assets for target platform
Development Build Adds debug symbols and logs to build

All lessons in Expert