Unity Magic Leap Automated Build

For Continuous Integration of Magic Leap Unity Applications

1) In Unity, in your Assets folder, create a folder named 'Editor'

2) Create the an empty script, inside the 'Editor' folder. Be sure to name the script file: 'MyEditorScript'

3) Double click the script, to open it in Visual Studio and edit it as follows (changing the paths):

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using UnityEditor;

using UnityEditor.Build.Reporting;

public class MyEditorScript : MonoBehaviour {

// Use this for initialization

void Start () {

}

// Update is called once per frame

void Update () {

}

public static void PerformBuild()

{

string[] scenes = { };

BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions();

buildPlayerOptions.scenes = new[] { "Assets/Scenes/your_scene.unity" };

buildPlayerOptions.locationPathName = "/path/to/your/unityproject/yourapp.mpk";

buildPlayerOptions.target = UnityEditor.BuildTarget.Lumin;

BuildReport report = BuildPipeline.BuildPlayer(buildPlayerOptions);

BuildSummary summary = report.summary;

if (summary.result == BuildResult.Succeeded)

{

Debug.Log("Build succeeded: " + summary.totalSize + " bytes");

}

if (summary.result == BuildResult.Failed)

{

Debug.Log("Build failed");

}

}

}

4) In Visual Studio, click on Build All, to build the script. This will build the 'MyEditorScript.cs.meta' file.

5) Execute the commandline: /Applications/Unity/Unity.app/Contents/MacOS/Unity -quit -batchmode -username 'your@email' -password 'your_password' -projectPath '/path/to/your/unityproject' -buildTarget Lumin -executeMethod MyEditorScript.PerformBuild

6) Check ~/Library/Logs/Unity/Editor.log for any errors/status of the build

7) If all goes well you should see the following two files:

/path/to/your/unityproject/yourapp.mpk

/path/to/your/unityproject/com.yourcompany.yourapp.package

Rodney Degracia

October 2018