unity的專案手動打包確實很痛苦,得慢慢等著,好無聊,能自動化指令碼打包什麼的最好了,閒話不多說直接上指令碼。
c#**windows的bat指令碼
echo off
set companyname="公司名字"
set productname="遊戲名字"
set platform=0 //這個是平台編號
set outpath="打包輸出路徑 例如:e:\1\build"
set arg0="引數1,誰便定義吧"
set icon="遊戲圖示路徑,例如:e:\2\icon.png"
set assetresource="遊戲的resources目錄,例如:e:\1\game\assets\resources"
set font="e:\2\data\resource\font\simkai.ttf"
xcopy %icon% %assetresource% /y
xcopy %font% %assetresource% /y
echo "packaging......"
start /wait d:\unity5.3\unity\editor\unity.exe -quit -batchmode -projectpath "e:\1\game" -executemethod projectbuild.buildpackage %companyname% %productname% %platform% %outpath% %arg0%
echo "build package done"
pause
看到這兒你可能會問bat指令碼在其他系統怎麼破,額,額,額,好尷尬,那就來個python版本的吧,如下:`
public class projectbuild : editor
else if (target.equals("1")) //android
else if (target.equals("2")) //ios
//其他平台自己看著寫就行
s = null;
}static void buildforandroid()
;string path= getexportpath(buildtarget.android);
buildpipeline.buildplayer(levels, path, buildtarget.android, buildoptions.none);
}static void buildforios()
;string path = getexportpath(buildtarget.ios);
buildpipeline.buildplayer(levels, path, buildtarget.ios, buildoptions.none);
}[menuitem("a/b")]
static void buildforstandalonewindows()
;string path = getexportpath(buildtarget.standalonewindows);
playersettings.defaultisfullscreen = false;
playersettings.companyname = companyname;
playersettings.productname = productname;
playersettings.resizablewindow = false;
playersettings.displayresolutiondialog = resolutiondialogsetting.disabled;
var tx = resources.load("icon");
texture2d txs = ;
var lengt = playersettings.geticonsfortargetgroup(buildtargetgroup.standalone);
if(txs!=null)
playersettings.seticonsfortargetgroup(buildtargetgroup.standalone, txs);
var st= buildpipeline.buildplayer(levels,path, buildtarget.standalonewindows, buildoptions.none);
}private static string getexportpath(buildtarget target)
else if (target == buildtarget.ios)
else if (target == buildtarget.standalonewindows)
unityengine.debug.log(path);
unityengine.debug.log(name);
string exepath = @path + name;
unityengine.debug.log(exepath);
return exepath;
}private static string companyname
}private static string productname }}
`
`
#!/user/bin/python
#coding=utf-8
import subprocess
import shutil
import os
unitypath="d:/unity5.3/unity/editor/unity.exe"
companyname="公司名字"
productname="遊戲名字"
platform="0"
outpath="e:/1/game/build"
arg0="引數誰便定義"
icon="e:/1/icon.png"
assetresource="e:/1/game/assets/resources"
font="e:/data/font/simkai.ttf"
print "package start......"
shutil.copy(icon,assetresource)
print "複製"+icon+"到 "+assetresource
shutil.copy(font,assetresource)
print "複製"+font+"到"+assetresource
print "packing......"
print "build package done"
`
iOS自動打包指令碼
最近比較對指令碼感興趣,但是學起來,感覺不但很多編輯器,而且指令碼種類眾多,而且實現方法也比較多,所以所學以shell指令碼為準,編輯器以vim,但是大同小異,大家也可以參考。首先貼上 bin sh 工程絕對路徑 cd 1 project path pwd build資料夾路徑 build path...
iOS自動打包指令碼
ios自動打包指令碼,並實現素材 文字資源 部分 的替換和重簽名,基於python實現。config.py 配置指令碼 autopackage.py 自動化指令碼 prepareimagestool.py 拷貝工程中的結構出來用來更換後準備替換 2 伺服器的ip位址 3 反饋郵箱 6 在mac電腦中...
Unity自動化打包注意事項
使用unity手冊上介紹的程式啟動引數,在不開啟unity editor介面的情況下自動執行c 可以實現自動打包。如果是專門打包ios包的話,一切ok。但是一旦在android與ios之間切換,就會發現ios的postprocessbuild標記的後處理 沒有執行,造成打包流程出錯。出現該問題的原因...