打包工具完善
This commit is contained in:
parent
5e469d538f
commit
67dfdf94c6
8
Assets/Editor/BFBuildProjectTools/AssetBundleWindow.meta
Normal file
8
Assets/Editor/BFBuildProjectTools/AssetBundleWindow.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0c41a7273e266a0468c52d3a52652dbd
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -0,0 +1,195 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace BFEditor.Build
|
||||||
|
{
|
||||||
|
public class CompareAssetBundleWindow : EditorWindow
|
||||||
|
{
|
||||||
|
private string newestABPath = "";
|
||||||
|
private string lastABPath = "";
|
||||||
|
public bool IsAndroid = true;
|
||||||
|
private List<string> ABList = new List<string>();
|
||||||
|
Vector2 resultScrollPos;
|
||||||
|
public CompareAssetBundleWindow()
|
||||||
|
{
|
||||||
|
titleContent = new GUIContent("AssetBundle对比");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnEnable()
|
||||||
|
{
|
||||||
|
GetNewestABPath();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnGUI()
|
||||||
|
{
|
||||||
|
GUILayout.Space(18);
|
||||||
|
GUILayout.BeginHorizontal();
|
||||||
|
GUILayout.Label("当前版本AB路径");
|
||||||
|
GUILayout.TextField(newestABPath, GUILayout.Width(600));
|
||||||
|
if (GUILayout.Button("选择", GUILayout.Width(80)))
|
||||||
|
{
|
||||||
|
string openPath = EditorUtility.OpenFolderPanel("select ab path", newestABPath, "");
|
||||||
|
if (openPath.CompareTo("") != 0){
|
||||||
|
newestABPath = openPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
GUILayout.Space(10);
|
||||||
|
|
||||||
|
GUILayout.BeginHorizontal();
|
||||||
|
GUILayout.Label("上个版本AB路径");
|
||||||
|
GUILayout.TextField(lastABPath, GUILayout.Width(600));
|
||||||
|
if (GUILayout.Button("选择", GUILayout.Width(80)))
|
||||||
|
{
|
||||||
|
string openPath = EditorUtility.OpenFolderPanel("select ab path", lastABPath, "");
|
||||||
|
if (openPath.CompareTo("") != 0){
|
||||||
|
lastABPath = openPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
GUILayout.Space(10);
|
||||||
|
|
||||||
|
GUILayout.BeginHorizontal();
|
||||||
|
GUILayout.Space(150);
|
||||||
|
if (GUILayout.Button("对比", GUILayout.Width(200), GUILayout.Height(40)))
|
||||||
|
{
|
||||||
|
CheckMD5AndAssetHash();
|
||||||
|
}
|
||||||
|
|
||||||
|
GUILayout.Space(100);
|
||||||
|
if (GUILayout.Button("使用上个版本的AB修复", GUILayout.Width(200), GUILayout.Height(40)))
|
||||||
|
{
|
||||||
|
UseLastABFix();
|
||||||
|
}
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
GUILayout.Space(30);
|
||||||
|
|
||||||
|
DrawResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawResult()
|
||||||
|
{
|
||||||
|
resultScrollPos = GUILayout.BeginScrollView(resultScrollPos, GUILayout.Width(800), GUILayout.Height(620));
|
||||||
|
for (int i = ABList.Count - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
var path = ABList[i];
|
||||||
|
|
||||||
|
GUILayout.BeginHorizontal();
|
||||||
|
GUILayout.Space(20);
|
||||||
|
EditorGUILayout.TextField(path);
|
||||||
|
|
||||||
|
GUILayout.Space(10);
|
||||||
|
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
}
|
||||||
|
GUILayout.EndScrollView();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckMD5AndAssetHash()
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(newestABPath))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(lastABPath))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ABList.Clear();
|
||||||
|
var manifestPath = System.IO.Path.Combine(newestABPath, "asset_bundle_manifest.ab");
|
||||||
|
var manifestAB = AssetBundle.LoadFromFile(manifestPath);
|
||||||
|
var Manifest = manifestAB.LoadAsset<AssetBundleManifest>("AssetBundleManifest");
|
||||||
|
manifestAB.Unload(false);
|
||||||
|
|
||||||
|
var lastManifestPath = System.IO.Path.Combine(lastABPath, "asset_bundle_manifest.ab");
|
||||||
|
var lastManifestAB = AssetBundle.LoadFromFile(lastManifestPath);
|
||||||
|
var lastManifest = lastManifestAB.LoadAsset<AssetBundleManifest>("AssetBundleManifest");
|
||||||
|
lastManifestAB.Unload(false);
|
||||||
|
|
||||||
|
var allAB = Manifest.GetAllAssetBundles();
|
||||||
|
foreach(var path in allAB)
|
||||||
|
{
|
||||||
|
if (path.Contains("ab_config.bytes") || path.Contains("asset_bundle_manifest.ab"))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
var fullPathA = Path.Combine(newestABPath, path);
|
||||||
|
var fullPathB = Path.Combine(lastABPath, path);
|
||||||
|
if (File.Exists(fullPathB) && BF.GameLaunchUtils.GetFileMD5(fullPathA).CompareTo(BF.GameLaunchUtils.GetFileMD5(fullPathB)) != 0)
|
||||||
|
{
|
||||||
|
if (Manifest.GetAssetBundleHash(path) == lastManifest.GetAssetBundleHash(path))
|
||||||
|
{
|
||||||
|
// md5 不一致但是AssetHash一致的情况
|
||||||
|
ABList.Add(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UseLastABFix()
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(newestABPath))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(lastABPath))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ABList.Count == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
foreach(var path in ABList)
|
||||||
|
{
|
||||||
|
var fullPathA = Path.Combine(newestABPath, path);
|
||||||
|
var fullPathB = Path.Combine(lastABPath, path);
|
||||||
|
File.Copy(fullPathB, fullPathA, true);
|
||||||
|
}
|
||||||
|
var version = newestABPath.Substring(newestABPath.Replace("\\", "/").LastIndexOf("/") + 1);
|
||||||
|
AssetBundleUtils.RegenerateABConfigMd5(newestABPath, version);
|
||||||
|
|
||||||
|
ABList.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ShowWindow()
|
||||||
|
{
|
||||||
|
var window = GetWindow<CompareAssetBundleWindow>();
|
||||||
|
window.Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GetNewestABPath()
|
||||||
|
{
|
||||||
|
var bundleCachePath = IsAndroid ? Application.dataPath + "/../HistoryAssetBundles" : Application.dataPath + "/../HistoryAssetBundles/IOS";
|
||||||
|
var dirInfo = new DirectoryInfo(bundleCachePath);
|
||||||
|
var dirs = dirInfo.GetDirectories();
|
||||||
|
if (dirs.Length == 0)
|
||||||
|
{
|
||||||
|
newestABPath = "";
|
||||||
|
lastABPath = "";
|
||||||
|
}
|
||||||
|
if (dirs.Length == 1)
|
||||||
|
{
|
||||||
|
newestABPath = dirs[0].FullName;
|
||||||
|
lastABPath = "";
|
||||||
|
}
|
||||||
|
var hightestIndex = 0;
|
||||||
|
var secondIndex = 0;
|
||||||
|
for (var i = 1; i < dirs.Length; i++)
|
||||||
|
{
|
||||||
|
if (dirs[i].FullName.CompareTo(dirs[hightestIndex].FullName) > 0)
|
||||||
|
{
|
||||||
|
secondIndex = hightestIndex;
|
||||||
|
hightestIndex = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
newestABPath = dirs[hightestIndex].FullName;
|
||||||
|
if (hightestIndex > 0)
|
||||||
|
{
|
||||||
|
lastABPath = dirs[secondIndex].FullName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ea05efeb3467b0947b735c8fe281cb8c
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -192,6 +192,24 @@ namespace BFEditor.Build
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[MenuItem("打包工具/AssetBundles/对比上一个版本AB Android", priority = 207)]
|
||||||
|
static void CompareLastVersionABAndroid()
|
||||||
|
{
|
||||||
|
var window = (CompareAssetBundleWindow)EditorWindow.GetWindowWithRect(typeof(CompareAssetBundleWindow),
|
||||||
|
new Rect(Screen.width / 2, Screen.height / 2, 800, 800), true);
|
||||||
|
window.IsAndroid = true;
|
||||||
|
window.Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
[MenuItem("打包工具/AssetBundles/对比上一个版本AB IOS", priority = 208)]
|
||||||
|
static void CompareLastVersionABIOS()
|
||||||
|
{
|
||||||
|
var window = (CompareAssetBundleWindow)EditorWindow.GetWindowWithRect(typeof(CompareAssetBundleWindow),
|
||||||
|
new Rect(Screen.width / 2, Screen.height / 2, 800, 800), true);
|
||||||
|
window.IsAndroid = false;
|
||||||
|
window.Show();
|
||||||
|
}
|
||||||
|
|
||||||
[MenuItem("打包工具/打包窗口", priority = 301)]
|
[MenuItem("打包工具/打包窗口", priority = 301)]
|
||||||
static void ShowBuildWindow()
|
static void ShowBuildWindow()
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user