- Home /
Batch File and Script to Make Multiple Builds
I have been trying to create a batch file that I can run to call a script to make multiple builds. However, the batch starts and exits without printing any useful information, so I was wondering if you could help me identify something I may have overlooked. Thank you in advance.
Batch: %UNITY% -batchmode -nographics -quit -projectPath %~dp0 -executedMethod BuildUnityPlayer.PerformBuild
Script:
using UnityEngine;
using System.Collections;
using System;
using UnityEditor;
public class BuildUnityPlayer : MonoBehaviour {
public static void PerformBuild()
{
// the scenes we want to include in the build
string[] scenes = { "Scenes/A.unity",
"Scenes/B.unity",
"Scenes/C.unity"
};
DateTime currentDate = DateTime.Now;
string buildName = "Game-"+currentDate.ToShortDateString();
// build for windows stand alone
string windowsStandAloneBuildName = buildName+"-StandAlone.exe";
EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.StandaloneWindows);
BuildPipeline.BuildPlayer(scenes, windowsStandAloneBuildName, BuildTarget.StandaloneWindows, BuildOptions.None);
// build for web player
string webplayerBuildName = buildName+"-WebPlayer.exe";
EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.WebPlayer);
BuildPipeline.BuildPlayer(scenes, webplayerBuildName, BuildTarget.WebPlayer, BuildOptions.None);
}
}
No Unity is closed when I run the batch. I run this line just before the build command:
:: Can't run more than one copy of Unity at a time.
taskkill /I$$anonymous$$ Unity.exe /f
I saw some other examples do it the way I am. I ensured my scenes names were correct as well.
I have also tried moving the script to the same directory and within the project's scripts directory. Both have failed.
add this to the param list so you can get the exact error "-logFile unitylog.txt"
Thank you. That confirmed that the builds are completing. I get batch was successful in the log, but I still don't see any builds in the directory at all.
Answer by jaised · Apr 17, 2013 at 07:40 PM
Right-clicking the batch and "Run as Administrator" fixed my issue. Thank you.
You can use the u$$anonymous$$ate package from the asset store http://u3d.as/4rA. It is an automation tool for unity. It contains several actions like 'build player' and 'set scenes' which can be combine to a automation plan.
The project page contains a tutorial video that shows how to build multiple player for one project with u$$anonymous$$ate. http://docs.ancientlightstudios.com/display/UT/Getting+started+with+u$$anonymous$$ate
Your answer
Follow this Question
Related Questions
How to create a BuildOptions mask in the Editor Window? 2 Answers
SwitchActiveBuildTarget vs. buildTarget 0 Answers
Unity Build Memory Usage Patterns 0 Answers
Getting the current BuildOptions 1 Answer