Build settings configuration helps you choose how and where your game or app will run. It sets up the platform, scenes, and options before making the final build.
0
0
Build settings configuration in Unity
Introduction
When you want to create a version of your game for a specific device like PC, mobile, or console.
When you need to select which scenes should be included in the final game build.
When you want to change build options like development mode or compression.
When you want to switch between platforms to test your game on different devices.
When preparing your game for release or testing on a new platform.
Syntax
Unity
using UnityEditor;
// Set build target
EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows64);
// Define scenes to include
string[] scenes = {"Assets/Scene1.unity", "Assets/Scene2.unity"};
// Build player
BuildPipeline.BuildPlayer(scenes, "Builds/MyGame.exe", BuildTarget.StandaloneWindows64, BuildOptions.None);You use EditorUserBuildSettings to change the platform you want to build for.
BuildPipeline.BuildPlayer creates the final game with chosen scenes and options.
Examples
This switches the build target to Android platform.
Unity
EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Android, BuildTarget.Android);
This builds the Android app including only the MainScene.
Unity
string[] scenes = {"Assets/MainScene.unity"};
BuildPipeline.BuildPlayer(scenes, "Builds/MyGame.apk", BuildTarget.Android, BuildOptions.None);This builds a Windows development version with debugging enabled.
Unity
BuildPipeline.BuildPlayer(scenes, "Builds/MyGame.exe", BuildTarget.StandaloneWindows64, BuildOptions.Development);Sample Program
This script switches the build target to Windows 64-bit, includes two scenes, and builds the game executable. It then logs a message when done.
Unity
using UnityEditor; using UnityEngine; public class BuildScript { public static void BuildWindowsGame() { // Switch to Windows 64-bit build target EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows64); // Scenes to include in build string[] scenes = {"Assets/Scene1.unity", "Assets/Scene2.unity"}; // Build the player BuildPipeline.BuildPlayer(scenes, "Builds/MyGame.exe", BuildTarget.StandaloneWindows64, BuildOptions.None); // Inform user Debug.Log("Build complete: MyGame.exe"); } }
OutputSuccess
Important Notes
Build scripts run inside the Unity Editor, not in the final game.
Make sure all scenes you want are added to the build scenes list.
Switching build targets can take some time as Unity reimports assets.
Summary
Build settings configure where and how your game is built.
You select platform, scenes, and options before building.
Use build scripts to automate building inside Unity Editor.