ios自动打包脚本提交
parent
943c04917e
commit
639aa6c32b
|
|
@ -5,9 +5,9 @@ using System;
|
|||
|
||||
public class AutoPack : EditorWindow
|
||||
{
|
||||
bool isObb = false;
|
||||
static bool isObb = false;
|
||||
bool isBuild = false;
|
||||
bool isZs = false;
|
||||
static bool isZs = false;
|
||||
static string[] versionArr = new string[15];
|
||||
int verIndex = 0;
|
||||
static string curProjectDir;
|
||||
|
|
@ -16,13 +16,15 @@ public class AutoPack : EditorWindow
|
|||
private static void EzBuildPack()
|
||||
{
|
||||
curProjectDir = Environment.CurrentDirectory.Replace('\\', '/');
|
||||
Debug.Log("当前工程路径:"+curProjectDir);
|
||||
string[] _strArr = Directory.GetFiles(curProjectDir + "/AssetBundles/", "*.txt");
|
||||
Debug.Log("version列表数量:"+_strArr.Length);
|
||||
for (int i = 0; i < _strArr.Length; i++)
|
||||
{
|
||||
string _str = _strArr[i].Split('/')[4];
|
||||
string[] pathSpl = _strArr[i].Split('/');
|
||||
string _str = pathSpl[pathSpl.Length-1];
|
||||
versionArr[i] = _str;
|
||||
}
|
||||
Debug.Log("versionArr :" + versionArr.Length + versionArr[0]);
|
||||
//创建窗口
|
||||
Rect wr = new Rect(0, 0, 400, 500);
|
||||
var buildWin = GetWindowWithRect<AutoPack>(wr, true);
|
||||
|
|
@ -37,11 +39,13 @@ public class AutoPack : EditorWindow
|
|||
EditorGUILayout.Space();
|
||||
verIndex = EditorGUILayout.Popup("选择version配置文件:", verIndex, versionArr);
|
||||
EditorGUILayout.Space();
|
||||
#if UNITY_ANDROID
|
||||
isObb = EditorGUILayout.ToggleLeft("是否导出obb包", isObb);
|
||||
#endif
|
||||
isBuild = EditorGUILayout.ToggleLeft("是否需要build资源", isBuild);
|
||||
isZs = EditorGUILayout.ToggleLeft("是否从正式场景导出", isZs);
|
||||
EditorGUILayout.Space();
|
||||
if (GUILayout.Button("导出Android工程", GUILayout.Height(40f)))
|
||||
if (GUILayout.Button("导出工程", GUILayout.Height(40f)))
|
||||
{
|
||||
Debug.Log("开始导出工程");
|
||||
string targetPath = Application.dataPath + "/Resources/version.txt";
|
||||
|
|
@ -62,21 +66,27 @@ public class AutoPack : EditorWindow
|
|||
GameEditor.ResourcesPathEditor.CreateResourcePathConfig();
|
||||
Debug.Log("完成build资源");
|
||||
}
|
||||
|
||||
#if UNITY_ANDROID
|
||||
string sceneName = "Assets/LuaFramework/Scenes/LogoHwTest.unity";
|
||||
if (isZs)
|
||||
{
|
||||
sceneName = "Assets/LuaFramework/Scenes/LogoHwRelease.unity";
|
||||
}
|
||||
ExportAS(isObb, sceneName);
|
||||
ExportAS( sceneName);
|
||||
#elif UNITY_IOS
|
||||
string sceneName = "Assets/LuaFramework/Scenes/Logo.unity";
|
||||
ExportXcode(sceneName);
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
public static void ExportAS(bool _isobb, string _sceneName)
|
||||
public static void ExportAS( string _sceneName)
|
||||
{
|
||||
PlayerSettings.productName = "ex_android_jl";
|
||||
PlayerSettings.Android.useAPKExpansionFiles = _isobb;
|
||||
PlayerSettings.Android.useAPKExpansionFiles = isObb;
|
||||
string outPath = "D:/exAndroid/unity_ex_as";
|
||||
if (_isobb)
|
||||
if (isObb)
|
||||
{
|
||||
outPath = "D:/exAndroid/unity_ex_obb";
|
||||
}
|
||||
|
|
@ -99,6 +109,37 @@ public class AutoPack : EditorWindow
|
|||
Debug.Log("导出完成");
|
||||
///打开python工具所在路径
|
||||
GameEditor.Core.DataConfig.ConfigExportWindow.OpenDirectory("C:/Users/aaa/Desktop/pythonPack");
|
||||
}
|
||||
|
||||
private static void ExportXcode(string _sceneName)
|
||||
{
|
||||
PlayerSettings.productName = "太初行";
|
||||
string mainXcodePath =
|
||||
isZs? "/Volumes/ELEMENTS/JieLing/Packager/IOS/MHT_HW_RELEASE": "/Volumes/ELEMENTS/JieLing/Packager/IOS/MHT_HW_TEST";
|
||||
string outPath = isZs?"/Volumes/ELEMENTS/JieLing/Packager/IOS/exXcodePro_Release":"/Volumes/ELEMENTS/JieLing/Packager/IOS/exXcodePro_Test";
|
||||
if (Directory.Exists(outPath))
|
||||
{
|
||||
Directory.Delete(outPath, true);
|
||||
}
|
||||
// 设置需要打包的场景
|
||||
string launchScene = _sceneName;
|
||||
Debug.Log("打包场景:" + launchScene);
|
||||
BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions();
|
||||
buildPlayerOptions.locationPathName = outPath;
|
||||
buildPlayerOptions.options = BuildOptions.None;
|
||||
buildPlayerOptions.options |= BuildOptions.AcceptExternalModificationsToPlayer;
|
||||
buildPlayerOptions.scenes = new[] { launchScene };
|
||||
buildPlayerOptions.target = BuildTarget.iOS;
|
||||
// 调用开始打包
|
||||
BuildPipeline.BuildPlayer(buildPlayerOptions);
|
||||
|
||||
if (Directory.Exists(mainXcodePath))
|
||||
{
|
||||
Debug.Log("替换xcode资源");
|
||||
Directory.Delete(mainXcodePath+"/Data", true);
|
||||
Directory.Move(outPath+"/Data",mainXcodePath+"/Data");
|
||||
Directory.Delete(mainXcodePath+"/Classes/Native", true);
|
||||
Directory.Move(outPath+"/Classes/Native",mainXcodePath+"/Classes/Native");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue