bat打包unity的exe
程序员文章站
2022-06-04 15:10:43
...
参考:https://blog.csdn.net/qq_37601496/article/details/83991061
@echo on
set UNITY_PATH=“C:\Program Files\Unity\Editor\Unity.exe”
set UNITY_PROJECT_PATH=D:\xxxx
set UNITY_METHOD_NAME=BuilderApk.BuildMyAndroidApk
set UNITY_LOG_PATH=D:\exe\BatunityApk_log.txt
%UNITY_PATH% -quit -batchmode -logFile %UNITY_LOG_PATH% -projectPath %UNITY_PROJECT_PATH% -executeMethod %UNITY_METHOD_NAME%
echo 4.打包成功
pause
using System.Collections.Generic;
using UnityEditor;
public class BuilderApk : Editor
{
[MenuItem("BuildApk/BuildMyAndroidApk")]
public static void BuildMyAndroidApk()
{
string outputPath = "D:\\exe\\xx.exe"; //输出的安装包路径目录
BuildOptions buildOption = BuildOptions.None;
outputPath = outputPath.Replace('\\', '/');
BuildPipeline.BuildPlayer(GetBuildScenes(), outputPath, BuildTarget.StandaloneWindows, buildOption);
}
/// <summary>
/// 取得要打包的场景
/// </summary>
/// <returns></returns>
static string[] GetBuildScenes()
{
List<string> pathList = new List<string>();
foreach (EditorBuildSettingsScene scene in EditorBuildSettings.scenes)
{
if (scene.enabled)
{
pathList.Add(scene.path);
}
}
return pathList.ToArray();
}
}