hch
2026-01-26 aa84cb62bebb9c8a4e586bcc1ec28eb7a16a8860
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#if UNITY_EDITOR
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using System.IO;
using UnityEditor;
 
public class RunTimeABLoadLog
{
    static List<string> assetBundleLoadLogs = new List<string>();
 
    public static void AddLog(string _abName, string _asset, string _scene)
    {
        var log = StringUtility.Concat(_scene, "\t", _abName, "\t", _asset, "\t", DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"));
        assetBundleLoadLogs.Add(log);
    }
 
    [MenuItem("程序/打印资源包加载日志")]
    public static void Print()
    {
        var tile = StringUtility.Concat("场景名", "\t", "资源包名", "\t", "资源名", "\t", "时间");
        assetBundleLoadLogs.Insert(0, tile);
        File.WriteAllLines(Application.dataPath + "/RunTimeABLoadLog.txt", assetBundleLoadLogs.ToArray());
    }
    [MenuItem("程序/打印热更标识")]
    public static void Print2()
    {
        string logicVersionMd5 = "00";
        string assetVersionMd5 = "00";
        // 初始化结果字节数组(MD5 是 16 字节)
        byte[] resultBytes = new byte[16];
 
        var outputPath = Application.dataPath.Replace("Assets", "AssetBundles");
        //判断是否有android目录
        if (Directory.Exists(outputPath + "/android"))
        {
            var lines = File.ReadAllLines(outputPath + "/android/logicbytes.txt");
 
            foreach (var line in lines)
            {
                var values = line.Split('\t');
                if (values.IsNullOrEmpty())
                {
                    continue;
                }
                var _md5 = values[values.Length - 1];
                // 对每个 MD5 进行异或运算
                byte[] md5Bytes = LoginManager.Instance.HexStringToByteArray(_md5);
                for (int j = 0; j < 16; j++)
                {
                    resultBytes[j] ^= md5Bytes[j];
                }
            }
            //取最后两位
            logicVersionMd5 = BitConverter.ToString(resultBytes).Replace("-", "").ToLower().Substring(14, 2);
 
 
            resultBytes = new byte[16];
            lines = File.ReadAllLines(outputPath + "/android/AssetsVersion.txt");
 
            foreach (var line in lines)
            {
                var values = line.Split('\t');
                if (values.IsNullOrEmpty())
                {
                    continue;
                }
                var _md5 = values[values.Length - 1];
                // 对每个 MD5 进行异或运算
                byte[] md5Bytes = LoginManager.Instance.HexStringToByteArray(_md5);
                for (int j = 0; j < 16; j++)
                {
                    resultBytes[j] ^= md5Bytes[j];
                }
            }
 
            assetVersionMd5 = BitConverter.ToString(resultBytes).Replace("-", "").ToLower().Substring(14, 2);
 
            Debug.Log($"Android RefreshHotVersion {logicVersionMd5}{assetVersionMd5}");
        }
        else
        {
            Debug.Log("没有android目录");
        }
 
        if (Directory.Exists(outputPath + "/ios"))
        {
            var lines = File.ReadAllLines(outputPath + "/android/logicbytes.txt");
 
            foreach (var line in lines)
            {
                var values = line.Split('\t');
                if (values.IsNullOrEmpty())
                {
                    continue;
                }
                var _md5 = values[values.Length - 1];
                // 对每个 MD5 进行异或运算
                byte[] md5Bytes = LoginManager.Instance.HexStringToByteArray(_md5);
                for (int j = 0; j < 16; j++)
                {
                    resultBytes[j] ^= md5Bytes[j];
                }
            }
            //取最后两位
            logicVersionMd5 = BitConverter.ToString(resultBytes).Replace("-", "").ToLower().Substring(14, 2);
 
 
            resultBytes = new byte[16];
            lines = File.ReadAllLines(outputPath + "/android/AssetsVersion.txt");
 
            foreach (var line in lines)
            {
                var values = line.Split('\t');
                if (values.IsNullOrEmpty())
                {
                    continue;
                }
                var _md5 = values[values.Length - 1];
                // 对每个 MD5 进行异或运算
                byte[] md5Bytes = LoginManager.Instance.HexStringToByteArray(_md5);
                for (int j = 0; j < 16; j++)
                {
                    resultBytes[j] ^= md5Bytes[j];
                }
            }
 
            assetVersionMd5 = BitConverter.ToString(resultBytes).Replace("-", "").ToLower().Substring(14, 2);
 
            Debug.Log($"Ios RefreshHotVersion {logicVersionMd5}{assetVersionMd5}");
        }
        else
        {
            Debug.Log("没有Ios目录");
        }
        
    }
}
#endif