NLDClient-yudde/ProjectNLD/Assets/_Test/Editor/TestCode.cs

104 lines
3.3 KiB
C#
Raw Normal View History

2025-05-22 18:57:44 +08:00
using System.Collections.Generic;
2025-05-12 16:56:34 +08:00
using System.IO;
using System.Text;
2025-05-22 18:57:44 +08:00
using Framework;
using Gameplay.UI.Common;
2025-05-26 13:20:31 +08:00
using Gameplay.Unit.Data;
2025-05-12 19:19:13 +08:00
using PhxhSDK.AOT;
2025-05-12 16:56:34 +08:00
using PhxhSDK.AOT.Encrypt;
using PhxhSDK.AOT.PreConfig;
using UnityEditor;
using UnityEngine;
2025-05-12 19:19:13 +08:00
using UnityFS;
public class TestCode: Editor
{
2025-05-22 18:57:44 +08:00
[MenuItem("Test/测试")]
2025-05-26 13:20:31 +08:00
public static void Test5()
{
var checkPath = "Art/Grass01/FlowerGroup_2 (8)";
var findObj = GameObjectEx.FindEx(checkPath);
DebugUtil.LogError("查找对象:" + checkPath + " 是否存在:" + (findObj != null));
2025-05-26 13:20:31 +08:00
}
// [MenuItem("Test/测试")]
2025-05-22 18:57:44 +08:00
public static void Test4()
{
var dataSkill = EditorTableManager.instance.tables.SkillConfig.DataList[0];
var cloneSkill = dataSkill.Clone();
cloneSkill.ReferIds.Add(100);
DebugUtil.LogError("refer equal:" + (dataSkill == cloneSkill));
DebugUtil.LogError("技能ID:" + dataSkill.ID + " cloneSkillID:" + cloneSkill.ID);
DebugUtil.LogError("referIds:" + dataSkill.ReferIds.Count + " cloneReferIds:" + cloneSkill.ReferIds.Count);
}
// [MenuItem("Test/测试")]
public static void Test3()
{
var testList = new List<int>();
for (int i = 0; i < 100; i++)
{
testList.Add(i);
}
var jsonStr = LitJson.JsonMapper.ToJson(testList);
Debug.LogError(jsonStr);
}
2025-05-12 18:34:09 +08:00
// [MenuItem("Test/测试")]
public static void Test2()
{
var encKey = "test lt enc key, this is just a test, please modify this by yourself";
var encBytes = Encoding.UTF8.GetBytes(encKey);
var encStr = "";
for (int i = 0; i < encBytes.Length; i++)
{
encStr += "0X" + encBytes[i].ToString("X2") + ", ";
}
Debug.LogError(encStr);
}
2025-05-22 18:57:44 +08:00
// [MenuItem("Test/测试")]
public static void Test()
{
2025-05-12 16:56:34 +08:00
var pathParent = "C:/Users/82158/Documents/WXWork/1688856871498430/Cache/File/2025-05";
var srcName = "defaultpackage_assets_hotupdatedlls_hotupdatedll.bundle";
var loadSrcBytes = File.ReadAllBytes(pathParent + "/" + srcName);
2025-05-12 18:34:09 +08:00
var encryptBytes = new byte[loadSrcBytes.Length];
for (int i = 0; i < loadSrcBytes.Length; i++)
{
var loadByte = loadSrcBytes[i];
encryptBytes[i] = LTSimpleEncrypt.Change(loadByte, i);
}
2025-05-12 19:19:13 +08:00
// 把加密后的数据写入到一个新文件中
var saveName = "encrypt_" + srcName;
var savePath = pathParent + "/" + saveName;
File.WriteAllBytes(savePath, encryptBytes);
var customFs = new CustomFileStream(savePath);
var decryptBytes = new byte[loadSrcBytes.Length];
customFs.Read(decryptBytes, 0, decryptBytes.Length);
2025-05-12 18:34:09 +08:00
for (int i = 0; i < encryptBytes.Length; i++)
2025-05-12 16:56:34 +08:00
{
2025-05-12 18:34:09 +08:00
var encryptByte = encryptBytes[i];
decryptBytes[i] = LTSimpleEncrypt.Change(encryptByte, i);
2025-05-12 16:56:34 +08:00
}
2025-05-12 16:56:34 +08:00
var isSame = true;
for (int i = 0; i < loadSrcBytes.Length; i++)
{
var loadSrcByte = loadSrcBytes[i];
2025-05-12 18:34:09 +08:00
var decryptByte = decryptBytes[i];
2025-05-12 16:56:34 +08:00
if (loadSrcByte != decryptByte)
{
isSame = false;
break;
}
}
2025-05-12 16:56:34 +08:00
Debug.LogError("测试结果:" + isSame);
}
}