'); -->

# Building from a command line

You can execute Unity3D scripts from the command line. If you’re aware of that then most probably you are interested in how to build your game project with Mad Level Manager.

To properly build your project, you need to make sure that your Build Configuration is synchronized with your Level Configuration. Here is a working example of how to build your game to three different platforms:

    using System;
    using System.Linq;
    using MadLevelManager;
    using UnityEditor;

    public class BuildMyGame {

        public static void BuildAndroid() {
            Build(BuildTarget.Android);
        }

        public static void BuildOSX() {
            Build(BuildTarget.StandaloneOSXIntel64);
        }

        public static void BuildWindows() {
            Build(BuildTarget.StandaloneWindows);
        }

        public static void Build(BuildTarget target) {
            var scenes = MadLevel.activeConfiguration.ScenesInOrder();
            var levels = from s in scenes select s.scenePath;
            BuildPipeline.BuildPlayer(levels.ToArray(), Environment.GetCommandLineArgs().Last(), target,
                BuildOptions.None);
        }
    }

Place this script in any Editor folder in your project and make sure that there’s no compilation errors! Then you can execute your Unity like this:

    C:\program files\Unity\Editor\Unity.exe -batchmode -projectPath=C:\Unity\MyGame -quit -batchmode -executeMethod BuildMyGame.BuildAndroid C:\Unity\MyGameBuild\MyGame.apk

Please see the documentation to better understand command line arguments.