Hey,
I’m working on setting up some automated builds and I’d like to be able to do it without using the unity editor. Unfortunately , while I can set up a build inside of the editor, the following code throws a weird “ECall methods must be packaged into a system module” exception when I try running it using Visual Studio.
using System;
using UnityEngine;
using UnityEditor;
namespace AutomatedBuilder
{
public class Builder
{
static int Main()
{
Builder buildUnityProject = new Builder();
buildUnityProject.buildProject();
return 0;
}
public Builder ()
{
}
public void buildProject()
{
string[] scenes = new string[] {"Assets/Scenes/login.unity", "Assets/Scenes/MainRoom.unity", "Assets/Scenes/LoadScene.unity"};
string filename = "Assets/GlobWorld2.unity3d";
UnityEditor.BuildPipeline.BuildPlayer(scenes, filename, UnityEditor.BuildTarget.WebPlayer, UnityEditor.BuildOptions.Development);
}
}
}
Any ideas on what could be wrong? I’ve included the UnityEditor and UnityEngine libraries and the code works if I run it in the editor by creating a button and having the button run the buildProject() code. I’m guessing that there must be something else I need to include in my visual studio project but I can’t think of anything else.