打包工具优化
parent
484089cd75
commit
6e4d1c8928
|
@ -2,6 +2,7 @@
|
|||
using UnityEditor;
|
||||
using System.IO;
|
||||
using System;
|
||||
using GameEditor.FrameTool;
|
||||
|
||||
public class AutoPack : EditorWindow
|
||||
{
|
||||
|
@ -9,13 +10,31 @@ public class AutoPack : EditorWindow
|
|||
bool isBuild = false;
|
||||
static bool isZs = false;
|
||||
static string[] versionArr = new string[15];
|
||||
int verIndex = 0;
|
||||
static int verIndex = 0;
|
||||
static string curProjectDir;
|
||||
static string m_ExcelPath;
|
||||
static string[] excelArr;
|
||||
static int excelIndex=0;
|
||||
//打包数据
|
||||
[MenuItem("自动化打包/一键导出")]
|
||||
private static void EzBuildPack()
|
||||
{
|
||||
curProjectDir = Environment.CurrentDirectory.Replace('\\', '/');
|
||||
|
||||
curProjectDir = Environment.CurrentDirectory.Replace('\\', '/');
|
||||
verIndex = EditorPrefs.GetInt("verIndex");
|
||||
m_ExcelPath = EditorPrefs.GetString("m_ExcelPath");
|
||||
excelArr = Directory.GetDirectories(m_ExcelPath, "master_*");
|
||||
Debug.Log(EditorPrefs.GetString("m_Bench"));
|
||||
if (excelArr!=null)
|
||||
{
|
||||
for (int i = 0; i < excelArr.Length; i++)
|
||||
{
|
||||
if (excelArr[i]== EditorPrefs.GetString("m_Bench"))
|
||||
{
|
||||
excelIndex = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
string[] _strArr = Directory.GetFiles(curProjectDir + "/AssetBundles/", "*.txt");
|
||||
Debug.Log("version列表数量:"+_strArr.Length);
|
||||
for (int i = 0; i < _strArr.Length; i++)
|
||||
|
@ -28,14 +47,39 @@ public class AutoPack : EditorWindow
|
|||
Rect wr = new Rect(0, 0, 400, 500);
|
||||
var buildWin = GetWindowWithRect<AutoPack>(wr, true);
|
||||
buildWin.titleContent = new GUIContent("打包工具");
|
||||
buildWin.Show();
|
||||
buildWin.Show();
|
||||
}
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
{
|
||||
EditorGUILayout.BeginVertical();
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.Space();
|
||||
if (excelArr!=null&& excelArr.Length>0)
|
||||
{
|
||||
excelIndex = EditorGUILayout.Popup("选择excel文件:", excelIndex, excelArr);
|
||||
EditorGUILayout.Space();
|
||||
if (GUILayout.Button("一键导表", GUILayout.Height(40f)))
|
||||
{
|
||||
EditorPrefs.SetString("m_Bench", excelArr[excelIndex]);
|
||||
GameEditor.Core.DataConfig.DataConfigWindow.excelALLConfig(false, excelArr[excelIndex] + "/base_data");
|
||||
}
|
||||
}
|
||||
if (GUILayout.Button("单打lua资源", GUILayout.Height(40f)))
|
||||
{
|
||||
if (FrameTool.BuildLuaAssetBundles())
|
||||
{
|
||||
string exportPath = GameEditor.AssetBundle.AssetBundleConfig.GetExportPath(EditorUserBuildSettings.activeBuildTarget);
|
||||
string targetPath = FrameTool.GetStreamingAssetPath(EditorUserBuildSettings.activeBuildTarget);
|
||||
File.Copy(exportPath + "/lzma/luabytes.unity3d", targetPath + "/lzma/luabytes.unity3d", true);
|
||||
File.Copy(exportPath + "/lzma/resconfigs.unity3d", targetPath + "/lzma/resconfigs.unity3d", true);
|
||||
File.Copy(exportPath + "/files.unity3d", targetPath + "/files.unity3d", true);
|
||||
}
|
||||
}
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.Space();
|
||||
verIndex = EditorGUILayout.Popup("选择version配置文件:", verIndex, versionArr);
|
||||
EditorGUILayout.Space();
|
||||
#if UNITY_ANDROID
|
||||
|
@ -47,6 +91,7 @@ public class AutoPack : EditorWindow
|
|||
if (GUILayout.Button("导出工程", GUILayout.Height(40f)))
|
||||
{
|
||||
Debug.Log("开始导出工程");
|
||||
EditorPrefs.SetInt("verIndex", verIndex);
|
||||
string targetPath = Application.dataPath + "/Resources/version.txt";
|
||||
string copyPath = curProjectDir + "/AssetBundles/" + versionArr[verIndex];
|
||||
Debug.Log("version文件路径:" + copyPath);
|
||||
|
@ -60,9 +105,9 @@ public class AutoPack : EditorWindow
|
|||
{
|
||||
Debug.Log("开始build资源");
|
||||
//打包游戏
|
||||
GameEditor.FrameTool.FrameTool.BuildGameAssetBundles();
|
||||
FrameTool.BuildGameAssetBundles();
|
||||
//拷贝AssetBundle到流媒体目录
|
||||
GameEditor.FrameTool.FrameTool.CopyAssetBundleToStreamingAssets();
|
||||
FrameTool.CopyAssetBundleToStreamingAssets();
|
||||
//刷新资源配置
|
||||
GameEditor.ResourcesPathEditor.CreateResourcePathConfig();
|
||||
Debug.Log("完成build资源");
|
||||
|
@ -85,7 +130,7 @@ public class AutoPack : EditorWindow
|
|||
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)
|
||||
{
|
||||
|
@ -137,7 +182,7 @@ public class AutoPack : EditorWindow
|
|||
BuildPipeline.BuildPlayer(buildPlayerOptions);
|
||||
Debug.Log("打包完成");
|
||||
Debug.Log("导出工程路径:"+ outPath);
|
||||
if (Directory.Exists(mainXcodePath))
|
||||
if (Directory.Exists(mainXcodePath)&& Directory.Exists(outPath))
|
||||
{
|
||||
Debug.Log("替换xcode资源");
|
||||
Directory.Delete(mainXcodePath+"/Data", true);
|
||||
|
|
Loading…
Reference in New Issue