Builder.cs
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
public class Builder : Editor
{
static public void Build()
{
string outputPath = Application.dataPath.Substring(0, Application.dataPath.Length - "Assets".Length) + "_Out/";
BuildOptions buildOption = BuildOptions.AcceptExternalModificationsToPlayer;
string[] ss = System.Environment.GetCommandLineArgs();
for (int i = 0; i < ss.Length; i++)
{
if (ss[i] == "-outputPath")
{
outputPath = ss[i + 1];
}
}
outputPath = outputPath.Replace('\\', '/');
BuildPipeline.BuildPlayer(GetBuildScenes(), outputPath, BuildTarget.Android, buildOption);
}
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();
}
}
----
suball.bat
call build.bat
cd..
call rename.bat
-----
rename.bat
del MainActivity-release-unsigned.apk
copy .\app\bin\MainActivity-release-unsigned.apk .\
if %time:~0,2% lss 10 (set d=%DATE:~0,4%%DATE:~5,2%%DATE:~8,2%%TIME:~1,1%%TIME:~3,2%%TIME:~6,2%)else (set d=%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2%)
rename .\MainActivity-release-unsigned.apk GTS_%d%.apk
copy GTS_%d%.apk \\192.168.8.190\共享目录\每日版本\sgz2018\185_%d%.apk
-----
clean.bat
cd app
ant clean
--------
build_unity.bat
@echo off
set BUILD_BAT_PATH=%cd%
set UNITY_PATH="E:\Unity4.7.2\Editor\Unity.exe"
set UNITY_PROJECT_NAME=app
set UNITY_PROJECT_PATH=%cd%\..\..\
set EXPORT_PROJECT_PATH=%cd%\app
set EXPORT_PROJECT_PATH_OUTPUT=%cd%
set EXTRA_PROJECT_DATA=%cd%\data
set UNITY_METHOD_NAME=Builder.Build
set UNITY_LOG_PATH=%cd%\unity_log.txt
echo 步骤1:清理文件夹
rem if exist %EXPORT_PROJECT_PATH% ( rd /s /q %EXPORT_PROJECT_PATH% )
echo 步骤2:调用UNITY 打包
%UNITY_PATH% -quit -batchmode -logFile %UNITY_LOG_PATH% -projectPath %UNITY_PROJECT_PATH% -executeMethod %UNITY_METHOD_NAME% -outputPath %EXPORT_PROJECT_PATH_OUTPUT%
------
build.bat
rd /s /q .\app\res
md .\app\res
xcopy .\res .\app\res /c/e/q
xcopy /y .\comm .\app /c/e/q/a
cd app
rem ant clean
ant release
rem copy .\bin\MainActivity-release.apk ..\
rem rename ..\MainActivity-release.apk test.apk
rem cd ..
-----
all.bat --
call build_unity.bat