| | |
| | | using Path = System.IO.Path; |
| | | using HybridCLR.Editor.HotUpdate; |
| | | using HybridCLR.Editor; |
| | | |
| | | using System.Text;
|
| | |
|
| | | namespace UnityEngine.AssetBundles |
| | | { |
| | | [System.Serializable] |
| | |
| | | |
| | | private void MakeBytesVersionFile() |
| | | { |
| | | ChangeBytes(); |
| | | var fileInfos = new List<FileInfo>(); |
| | | FileExtersion.GetAllDirectoryFileInfos(StringUtility.Contact(m_UserData.m_OutputPath, "/logicbytes"), fileInfos); |
| | | BytesVersionMaker.WriteAssetsVersionFile(Path.Combine(Directory.GetParent(Application.dataPath).FullName, m_UserData.m_OutputPath), fileInfos); |
| | |
| | | { |
| | | var fileInfos = new List<FileInfo>(); |
| | | FileExtersion.GetAllDirectoryFileInfos(m_UserData.m_OutputPath, fileInfos); |
| | | AssetsVersionMaker.WriteAssetsVersionFile(Path.Combine(Directory.GetParent(Application.dataPath).FullName, m_UserData.m_OutputPath), fileInfos); |
| | | AssetsVersionMaker.WriteAssetsVersionFile(Path.Combine(Directory.GetParent(Application.dataPath).FullName, m_UserData.m_OutputPath), fileInfos);
|
| | | |
| | | Debug.Log("生成AssetsVersion.txt文件完毕"); |
| | | } |
| | | |
| | | void ChangeBytes()
|
| | | {
|
| | | string path = StringUtility.Contact(m_UserData.m_OutputPath, "/logicbytes/");
|
| | | // 原始DLL字节内容文件的路径 |
| | | string originalDllBytesFilePath = path + "Assembly-CSharp.dll.bytes";
|
| | |
|
| | | // 临时文件的路径,用于写入"abc"后再追加原始DLL字节内容 |
| | | string tempFilePath = path + "temp_Assembly-CSharp.dll.bytes";
|
| | |
|
| | | // 要写入的字符串"abc" |
| | | string contentToWrite = "abc";
|
| | |
|
| | | // 将"abc"转换为字节数组 |
| | | byte[] abcBytes = Encoding.ASCII.GetBytes(contentToWrite);
|
| | |
|
| | | // 读取原始DLL字节内容到字节数组 |
| | | byte[] originalDllBytes = File.ReadAllBytes(originalDllBytesFilePath);
|
| | |
|
| | | // 将"abc"写入临时文件 |
| | | using (FileStream fs = new FileStream(tempFilePath, FileMode.Create, FileAccess.Write))
|
| | | {
|
| | | fs.Write(abcBytes, 0, abcBytes.Length);
|
| | |
|
| | | // 追加原始DLL字节内容到临时文件 |
| | | fs.Write(originalDllBytes, 0, originalDllBytes.Length);
|
| | | }
|
| | |
|
| | | ReplaceFile(tempFilePath, originalDllBytesFilePath);
|
| | | }
|
| | |
|
| | | public void ReplaceFile(string sourceFile, string targetFile)
|
| | | {
|
| | | // 确保源文件存在 |
| | | if (!File.Exists(sourceFile))
|
| | | {
|
| | | throw new FileNotFoundException("源文件未找到:" + sourceFile);
|
| | | }
|
| | |
|
| | | // 如果目标文件存在,则删除它 |
| | | if (File.Exists(targetFile))
|
| | | {
|
| | | File.Delete(targetFile);
|
| | | }
|
| | |
|
| | | // 将源文件重命名为目标文件 |
| | | File.Move(sourceFile, targetFile);
|
| | | }
|
| | |
|
| | | |
| | | static int packageIndex |
| | | { |
| | | get { return LocalSave.GetInt("ClientPackageIndex", 1); } |