0
0
Unityframework~20 mins

PC/Mac standalone build in Unity - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Standalone Build Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this Unity build script snippet?

Consider this C# script snippet used in Unity Editor to build a standalone PC/Mac application. What will be the output in the console after running this method?

Unity
using UnityEditor;
using UnityEngine;

public class BuildScript {
    public static void BuildGame() {
        string path = "Builds/MyGame.exe";
        BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions();
        buildPlayerOptions.scenes = new[] {"Assets/Scenes/Main.unity"};
        buildPlayerOptions.locationPathName = path;
        buildPlayerOptions.target = BuildTarget.StandaloneWindows64;
        buildPlayerOptions.options = BuildOptions.None;

        var report = BuildPipeline.BuildPlayer(buildPlayerOptions);
        if (report.summary.result == UnityEditor.Build.Reporting.BuildResult.Succeeded) {
            Debug.Log("Build succeeded: " + report.summary.totalSize + " bytes");
        } else {
            Debug.Log("Build failed");
        }
    }
}
ABuild succeeded: 0 bytes
BBuild failed
CBuild succeeded: [some positive number] bytes
DCompilation error due to missing using directive
Attempts:
2 left
💡 Hint

Think about what BuildPipeline.BuildPlayer returns and what the summary.totalSize represents.

🧠 Conceptual
intermediate
1:00remaining
Which build target should you choose for a Mac standalone build in Unity?

You want to create a standalone build for Mac OS using Unity. Which BuildTarget enum value should you use?

ABuildTarget.StandaloneWindows64
BBuildTarget.WebGL
CBuildTarget.iOS
DBuildTarget.StandaloneOSX
Attempts:
2 left
💡 Hint

Mac standalone builds require a specific target for Mac OS.

🔧 Debug
advanced
2:00remaining
Why does this PC build fail with 'Missing scenes' error?

Look at this build script snippet. The build fails with an error about missing scenes. What is the cause?

Unity
BuildPlayerOptions options = new BuildPlayerOptions();
options.scenes = new string[] {"Assets/Scenes/Level1.unity", "Assets/Scenes/Level2.unity"};
options.locationPathName = "Builds/MyGame.exe";
options.target = BuildTarget.StandaloneWindows64;
BuildPipeline.BuildPlayer(options);
AThe scene paths are incorrect or scenes are not added to the build settings
BThe locationPathName must end with .app for Windows builds
CBuildTarget.StandaloneWindows64 is deprecated and causes errors
DBuildPipeline.BuildPlayer requires a callback parameter
Attempts:
2 left
💡 Hint

Check if the scenes are included in the Unity build settings and if the paths are correct.

📝 Syntax
advanced
1:00remaining
Which option correctly sets the build location for a Mac standalone build?

Choose the correct way to set the build output path for a Mac standalone build in Unity.

Aoptions.locationPathName = "Builds/MyGame.app";
Boptions.locationPathName = "Builds/MyGame.exe";
Coptions.locationPathName = "Builds/MyGame";
Doptions.locationPathName = "Builds/MyGame.dmg";
Attempts:
2 left
💡 Hint

Mac standalone builds produce an application bundle with a specific extension.

🚀 Application
expert
1:30remaining
How many scenes will be included in this PC build?

Given this build script snippet, how many scenes will be included in the final build?

Unity
string[] scenes = new string[] {
    "Assets/Scenes/Main.unity",
    "Assets/Scenes/Intro.unity",
    "Assets/Scenes/Level1.unity"
};

BuildPlayerOptions options = new BuildPlayerOptions();
options.scenes = scenes;
options.locationPathName = "Builds/GameBuild.exe";
options.target = BuildTarget.StandaloneWindows64;
BuildPipeline.BuildPlayer(options);
A0
B3
C1
DDepends on build settings scenes
Attempts:
2 left
💡 Hint

When you specify scenes explicitly in BuildPlayerOptions, those scenes are included regardless of build settings.