- Home /
The question is answered, right answer was accepted
Build Player from Command Line
I've made a batch file with the following command line:
"C:\Program Files (x86)\Unity\Editor\Unity.exe" -batchMode -quit -nographics -projectPath C:\project -executeMethod AutoBuilder.PerformBuild
Which calls the following method:
static void PerformBuild ()
{
string[] scenes = { "1.unity","2.unity","3.unity","4.unity","5.unity" };
BuildPipeline.BuildPlayer(scenes,"win.exe",BuildTarget.StandaloneWindows,BuildOptions.None);
BuildPipeline.BuildPlayer(scenes,"osx.app",BuildTarget.StandaloneOSXUniversal,BuildOptions.None);
BuildPipeline.BuildPlayer(scenes,"WebPlayer.unity3d",BuildTarget.WebPlayerStreamed,BuildOptions.None);
scenes = null;
}
It does build the three players but unfortunately it only compiles one of them.
Is there anyway to force compile before building? Am I missing something?
EDIT:
I tried separating in different functions and different calls and the same thing happens, I get the 3 builds but only one has been compiled, the other 2 act as if there were no changes to the code.
"C:\Program Files (x86)\Unity\Editor\Unity.exe" -batchMode -quit -nographics -projectPath C:\project -executeMethod AutoBuilder.PerformWebBuild
"C:\Program Files (x86)\Unity\Editor\Unity.exe" -batchMode -quit -nographics -projectPath C:\project -executeMethod AutoBuilder.PerformWindowsBuild
"C:\Program Files (x86)\Unity\Editor\Unity.exe" -batchMode -quit -nographics -projectPath C:\project -executeMethod AutoBuilder.PerformWebBuild
The last build platform I had selected on the build settings.
have you had any success with this? What if you touch one of your code files between each call in the batch file?
Just as a note about C#, you don't need to null the scenes variable. It will be garbage collected the same way in either case. Nulling variables does NOT provide any hints to the garbage collector.
Answer by KvanteTore · Oct 26, 2011 at 11:31 AM
Presumably, you can use EditorUserBuildSettings.SwitchActiveBuildTarget to set the active build target before you build. I haven't tried it but I came across the method and thought about your problem :)
$$anonymous$$ay I know how it can work? Because I tried it in my build script by putting it right before the BuildPlayer call, and it doesn't work.
Answer by BerggreenDK · Aug 18, 2011 at 07:59 PM
If you place the command in a command file, eg. "compileall.cmd" and then make a function for each platform.
Then you can auto compile all three just by clicking on the CMD file.
would that be enough?
Won't that be the same as I have? I'll try it anyway.