Просмотр исходного кода

Merge branch 'main' of ssh://192.168.0.8:29418/xianjing into hy_dny

gdl_123 5 месяцев назад
Родитель
Сommit
e8a97c315f

+ 24 - 0
Assets/Editor/AssetBundle/AbNameHxInfo.cs

@@ -0,0 +1,24 @@
+using System.Collections.Generic;
+using UnityEngine;
+
+
+[System.Serializable]
+public class abNameInfo
+{
+    [SerializeField]
+    public string BaseName = "";
+    [SerializeField]
+    public string HxName = "";
+}
+
+
+[System.Serializable]
+public class AbNameHxInfo
+{
+    [SerializeField]
+    public string HxKey = "";
+
+    [SerializeField]
+    public List<abNameInfo> Infos = new List<abNameInfo>();
+}
+

+ 11 - 0
Assets/Editor/AssetBundle/AbNameHxInfo.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: ece087b38337e6647b5c609b557cc466
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 91 - 9
Assets/Editor/AssetBundle/CheckHotUpdateRes.cs

@@ -7,6 +7,10 @@ using System;
 using System.Reflection;
 using System.Reflection;
 using System.IO;
 using System.IO;
 using System.IO.Compression;
 using System.IO.Compression;
+using System.Security.Cryptography;
+using System.Text;
+using System.Linq;
+
 
 
 public class CheckHotUpdateRes : EditorWindow
 public class CheckHotUpdateRes : EditorWindow
 {
 {
@@ -58,7 +62,7 @@ public class CheckHotUpdateRes : EditorWindow
         //Debug.Log();
         //Debug.Log();
         info = AssetDatabase.LoadAssetAtPath<CheckResWindowInfo>(path);
         info = AssetDatabase.LoadAssetAtPath<CheckResWindowInfo>(path);
         info.InitTags();
         info.InitTags();
-        curResInfo = info.GetResInfo();
+         curResInfo = info.GetResInfo();
         if (curResInfo == null)
         if (curResInfo == null)
         {
         {
             curResInfo = new ResInfo();
             curResInfo = new ResInfo();
@@ -79,6 +83,7 @@ public class CheckHotUpdateRes : EditorWindow
         DrowSelectFolder("旧版本文件", "选择文件路径", "选择旧版本资源MD5文件路径", ref curResInfo.OldPath);
         DrowSelectFolder("旧版本文件", "选择文件路径", "选择旧版本资源MD5文件路径", ref curResInfo.OldPath);
         DrowSelectFolder("新版本文件", "选择文件路径", "选择新版本资源MD5文件路径", ref curResInfo.NewPath);   
         DrowSelectFolder("新版本文件", "选择文件路径", "选择新版本资源MD5文件路径", ref curResInfo.NewPath);   
         DrowSelectFolder("需跟新文件输出路径", "选择文件路径", "选择需跟新文件输出路径", ref curResInfo.OutputPath);
         DrowSelectFolder("需跟新文件输出路径", "选择文件路径", "选择需跟新文件输出路径", ref curResInfo.OutputPath);
+        DrowSelectFolder("ab包名基础名字文件路径", "选择文件路径", "选择ab包名基础名字文件路径", ref curResInfo.BaseNameFileInfoPath);
         DrawInfo();
         DrawInfo();
         DrawCheckBtn();
         DrawCheckBtn();
 
 
@@ -213,6 +218,11 @@ public class CheckHotUpdateRes : EditorWindow
         GUILayout.BeginHorizontal();
         GUILayout.BeginHorizontal();
         GUILayout.Space(60);
         GUILayout.Space(60);
         curResInfo.IsIgnore =GUILayout.Toggle(curResInfo.IsIgnore, "是否开启忽略某些文件") ;
         curResInfo.IsIgnore =GUILayout.Toggle(curResInfo.IsIgnore, "是否开启忽略某些文件") ;
+        GUILayout.Space(60);
+        if (GUILayout.Button("制作混淆信息"))
+        {
+           MakeAbHxNameAssets();
+        }
         GUILayout.EndHorizontal();
         GUILayout.EndHorizontal();
     }
     }
     private List<VersionInfoData> SerizlizeResList(byte[] data)
     private List<VersionInfoData> SerizlizeResList(byte[] data)
@@ -242,6 +252,14 @@ public class CheckHotUpdateRes : EditorWindow
 
 
         List<VersionInfoData> newlist = GetInfoDatas(newPath);
         List<VersionInfoData> newlist = GetInfoDatas(newPath);
         ChangeResMD5(newlist);
         ChangeResMD5(newlist);
+
+        Dictionary<string, string> abNamedic = null;
+        if (curResInfo.IsHx)
+        {
+            abNamedic= GetCurInfoAbNameInfos();
+        }
+
+
         if (Oldlist != null && newlist != null)
         if (Oldlist != null && newlist != null)
         {
         {
             int size = newlist.Count;
             int size = newlist.Count;
@@ -256,22 +274,26 @@ public class CheckHotUpdateRes : EditorWindow
 
 
                 bool isignore = false;
                 bool isignore = false;
 
 
-               
-                RG_Ignore_Info rG_Ignore_Info = curResInfo.Rg_Essential_Infos.FindFirst(it => !it.IsIgnore && newlist[i].FullName.Contains(it.Field));
+                string baseName = newlist[i].FullName; ;
+                RG_Ignore_Info rG_Ignore_Info = null;
+                if (curResInfo.IsHx && abNamedic.ContainsKey(newlist[i].FullName))
+                {
+
+                    baseName = abNamedic[newlist[i].FullName];
+                }
+                rG_Ignore_Info = curResInfo.Rg_Essential_Infos.FindFirst(it => !it.IsIgnore && baseName.Contains(it.Field));
 
 
                 bool isEssential = rG_Ignore_Info != null;
                 bool isEssential = rG_Ignore_Info != null;
 
 
                 if (curResInfo.IsIgnore && !isEssential)
                 if (curResInfo.IsIgnore && !isEssential)
                 {
                 {
-                    string igstr = curResInfo.IgnoreFiles.FindFirst(it => it == newlist[i].FullName);
-                    rG_Ignore_Info = curResInfo.rG_Ignore_Infos.FindFirst(it => it.IsIgnore && newlist[i].FullName.Contains( it.Field));
+                    string igstr = curResInfo.IgnoreFiles.FindFirst(it => it == baseName);
+                    rG_Ignore_Info = curResInfo.rG_Ignore_Infos.FindFirst(it => it.IsIgnore && baseName.Contains( it.Field));
                     if (!string.IsNullOrEmpty(igstr) || rG_Ignore_Info != null)
                     if (!string.IsNullOrEmpty(igstr) || rG_Ignore_Info != null)
                     {
                     {
                         isignore = true;
                         isignore = true;
-                        Debug.Log("=========忽略=============" + newlist[i].FullName);
-                    }
-
-                    
+                        Debug.Log("=========忽略=============" + baseName);
+                    }                   
                 }
                 }
 
 
                 VersionInfoData ores = Oldlist.FindFirst(it=> it.FullName == newlist[i].FullName);
                 VersionInfoData ores = Oldlist.FindFirst(it=> it.FullName == newlist[i].FullName);
@@ -443,4 +465,64 @@ public class CheckHotUpdateRes : EditorWindow
         string datapath = $"{Application.dataPath}/Content/Icons/";
         string datapath = $"{Application.dataPath}/Content/Icons/";
         FileHelper.CopyDir(datapath, curResInfo.OutputPath, "meta");
         FileHelper.CopyDir(datapath, curResInfo.OutputPath, "meta");
     }
     }
+
+
+
+    public static string GetABFileName(string abName,string s_ObscureKey)
+    {
+
+        try
+        {
+            using (var md5 = new MD5CryptoServiceProvider())
+            {
+                UTF8Encoding encoding = new UTF8Encoding(false);
+                byte[] bytes = encoding.GetBytes((abName + s_ObscureKey).ToLower());
+                bytes = md5.ComputeHash(bytes);
+                StringBuilder sb = new StringBuilder();
+                for (int i = 0; i < bytes.Length; i++)
+                {
+                    sb.Append(bytes[i].ToString("x2"));
+                }
+                return sb.ToString();
+            }
+        }
+        catch (Exception e)
+        {
+            Debug.LogException(e);
+        }
+
+        return abName;
+    }
+
+
+    private void MakeAbHxNameAssets()
+    {
+        List<VersionInfoData> baseData = GetInfoDatas(curResInfo.BaseNameFileInfoPath);
+        AbNameHxInfo hxInfo = curResInfo.abNameHxInfo == null? new AbNameHxInfo():curResInfo.abNameHxInfo;
+        if (hxInfo.Infos == null)
+            hxInfo.Infos = new List<abNameInfo>();
+        foreach (var item in baseData)
+        {
+            string hxName = GetABFileName(item.FullName,curResInfo.hxKey);
+            abNameInfo nameInfo = new abNameInfo() 
+            {
+                BaseName = item.FullName,
+                HxName = hxName,
+            };
+            hxInfo.Infos.Add(nameInfo);
+        }
+        curResInfo.abNameHxInfo = hxInfo;
+    }
+
+    public Dictionary<string,string> GetCurInfoAbNameInfos()
+    {
+        Dictionary<string, string> abinfos = new Dictionary<string, string>();
+
+        foreach (var item in curResInfo.abNameHxInfo.Infos)
+        {
+            abinfos.Add(item.HxName,item.BaseName);
+        }
+
+        return abinfos;
+    }
 }
 }

+ 6 - 0
Assets/Editor/AssetBundle/ResInfo.cs

@@ -25,6 +25,7 @@ public class ResInfo : ScriptableObject
 
 
     public string OutputPath = "C:/Users/Administrator/Desktop/My/项目/1";
     public string OutputPath = "C:/Users/Administrator/Desktop/My/项目/1";
 
 
+    public string BaseNameFileInfoPath = "";
     public string VersionFileName = "Version";
     public string VersionFileName = "Version";
 
 
     public string mainfestFileName = "mainfest";
     public string mainfestFileName = "mainfest";
@@ -37,4 +38,9 @@ public class ResInfo : ScriptableObject
     public int ChangeNum;
     public int ChangeNum;
     public bool IsIgnore = true;
     public bool IsIgnore = true;
     public BuildLanguage Language = BuildLanguage.cn;
     public BuildLanguage Language = BuildLanguage.cn;
+
+    public bool IsHx = false;
+    public string hxKey = "";
+
+    public AbNameHxInfo abNameHxInfo;
 }
 }