知了博客

集天地之精华,吸日月之灵气

« 深圳5条地铁线路获批复 5年后全部建成通车使用Nginx实现根据 IP 匹配指定 URL »

unity打包批处理备份

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

call clean.bat
cd ..
call build.bat
cd..
call rename.bat

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

日历

最新评论及回复

最近发表

Powered By Z-Blog 1.8 Arwen Build 90619 Code detection by Codefense  theme by BokeZhuti

Copyright know blog. Some Rights Reserved.站长(msn):webmaster#webgou.info(#换成@) 粤ICP备09183716号