#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
|