using System.Collections.Generic; using System.IO; using Sirenix.OdinInspector; using Sirenix.OdinInspector.Editor; using UnityEditor; using UnityEngine; namespace ZEditor { public class AutoCopyDllToCodesEditor : OdinEditorWindow { [MenuItem("Tool/自动复制热更dll到codes内")] static void Open() { GetWindow().Show(); } [FolderPath] public string dllPath = "HybridCLRData/HotUpdateDlls/StandaloneWindows64"; public List dllNames = new List() { "Hotfix.dll", "Hotfix.pdb" }; [FolderPath] public string codesPath = "Assets/Res/Codes"; [Button] void Copy() { DirectoryInfo infos = new DirectoryInfo(this.codesPath); var files = infos.GetFiles(); foreach (var fileInfo in files) { fileInfo.Delete(); } DirectoryInfo info = new DirectoryInfo(this.dllPath); var fileInfos = info.GetFiles(); foreach (var dllName in this.dllNames) { foreach (var fileInfo in fileInfos) { if (fileInfo.Name == dllName) { string str = $"{this.codesPath}/{dllName}.bytes"; fileInfo.CopyTo(str); Debug.Log($"copy {dllName}.bytes finish!!"); } } } AssetDatabase.Refresh(); Debug.Log("copy finish!!"); } } }