| | |
| | | public class VersionSelector : EditorWindow |
| | | { |
| | | public string buttonText = "Patch"; |
| | | public string[] options = new string[] { }; |
| | | public string[] options = new string[] {}; |
| | | public int index = 0; |
| | | public Action<int> callback = null; |
| | | |
| | |
| | | //system("mono ifix.exe [args]") |
| | | public static void CallIFix(List<string> args) |
| | | { |
| | | #if UNITY_EDITOR_OSX |
| | | #if UNITY_EDITOR_OSX || UNITY_EDITOR_LINUX |
| | | var mono_path = Path.Combine(Path.GetDirectoryName(typeof(UnityEngine.Debug).Module.FullyQualifiedName), |
| | | "../MonoBleedingEdge/bin/mono"); |
| | | if(!File.Exists(mono_path)) |
| | |
| | | //UnityEngine.Debug.Log(hotfix_injection.StartInfo.Arguments); |
| | | |
| | | StringBuilder exceptionInfo = null; |
| | | while (!hotfix_injection.StandardOutput.EndOfStream) |
| | | while(!hotfix_injection.StandardOutput.EndOfStream) |
| | | { |
| | | string line = hotfix_injection.StandardOutput.ReadLine(); |
| | | if (exceptionInfo != null) |
| | |
| | | { |
| | | InjectAllAssemblys(); |
| | | } |
| | | catch (Exception e) |
| | | catch(Exception e) |
| | | { |
| | | UnityEngine.Debug.LogError(e); |
| | | } |
| | | EditorUtility.ClearProgressBar(); |
| | | #if UNITY_2019_3_OR_NEWER |
| | | EditorUtility.RequestScriptReload(); |
| | | #endif |
| | | } |
| | | |
| | | public static bool AutoInject = true; //可以在外部禁用掉自动注入 |
| | |
| | | writer.Write(cfgItem.Value); |
| | | if (filters.Count > 0 && kv.Key == "IFix.IFixAttribute") |
| | | { |
| | | foreach (var method in cfgItem.Key.GetMethods(BindingFlags.Instance |
| | | | BindingFlags.Static | BindingFlags.Public |
| | | foreach(var method in cfgItem.Key.GetMethods(BindingFlags.Instance |
| | | | BindingFlags.Static | BindingFlags.Public |
| | | | BindingFlags.NonPublic | BindingFlags.DeclaredOnly)) |
| | | { |
| | | foreach (var filter in filters) |
| | | foreach(var filter in filters) |
| | | { |
| | | if ((bool)filter.Invoke(null, new object[] |
| | | { |
| | |
| | | |
| | | foreach (var path in |
| | | (from asm in AppDomain.CurrentDomain.GetAssemblies() |
| | | select Path.GetDirectoryName(asm.ManifestModule.FullyQualifiedName)).Distinct()) |
| | | select Path.GetDirectoryName(asm.ManifestModule.FullyQualifiedName)).Distinct()) |
| | | { |
| | | try |
| | | { |
| | |
| | | { |
| | | InjectAssembly(assembly); |
| | | } |
| | | |
| | | |
| | | //doBackup(DateTime.Now.ToString(TIMESTAMP_FORMAT)); |
| | | |
| | | AssetDatabase.Refresh(); |
| | |
| | | foreach (var file in Directory.GetFiles(dir)) |
| | | { |
| | | //排除调Editor下的东西 |
| | | if (file.IndexOf(Path.DirectorySeparatorChar + "Editor" + Path.DirectorySeparatorChar) > 0) |
| | | if (file.IndexOf(Path.DirectorySeparatorChar + "Editor" + Path.DirectorySeparatorChar) > 0 ) |
| | | { |
| | | continue; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | foreach (var subDir in Directory.GetDirectories(dir)) |
| | | foreach(var subDir in Directory.GetDirectories(dir)) |
| | | { |
| | | appendDirectory(src, subDir); |
| | | } |
| | |
| | | #if (UNITY_EDITOR || XLUA_GENERAL) && !NET_STANDARD_2_0 |
| | | } |
| | | #endif |
| | | } |
| | | catch { } |
| | | } catch { } |
| | | } |
| | | |
| | | cmd.AppendLine(compileTemplate); |
| | |
| | | //TODO: 目前的做法挺繁琐的,需要用户去获取Unity的编译命令文件,更好的做法应该是直接 |
| | | public static void Compile(string compileArgFile) |
| | | { |
| | | #if UNITY_EDITOR_OSX |
| | | #if UNITY_EDITOR_OSX || UNITY_EDITOR_LINUX |
| | | var monoPath = Path.Combine(Path.GetDirectoryName(typeof(UnityEngine.Debug).Module.FullyQualifiedName), |
| | | "../MonoBleedingEdge/bin/mono"); |
| | | var mcsPath = Path.Combine(Path.GetDirectoryName(typeof(UnityEngine.Debug).Module.FullyQualifiedName), |
| | |
| | | { |
| | | UnityEngine.Debug.Log(compileProcess.StandardOutput.ReadLine()); |
| | | } |
| | | |
| | | |
| | | compileProcess.WaitForExit(); |
| | | } |
| | | |
| | |
| | | scriptCompilationSettings.group = BuildTargetGroup.Android; |
| | | scriptCompilationSettings.target = BuildTarget.Android; |
| | | } |
| | | else if (platform == Platform.ios) |
| | | else if(platform == Platform.ios) |
| | | { |
| | | scriptCompilationSettings.group = BuildTargetGroup.iOS; |
| | | scriptCompilationSettings.target = BuildTarget.iOS; |
| | |
| | | } |
| | | } |
| | | |
| | | static void writeFields(BinaryWriter writer, List<FieldInfo> fields) |
| | | { |
| | | var fieldGroups = fields.GroupBy(m => m.DeclaringType).ToList(); |
| | | writer.Write(fieldGroups.Count); |
| | | foreach (var fieldGroup in fieldGroups) |
| | | { |
| | | writer.Write(GetCecilTypeName(fieldGroup.Key)); |
| | | writer.Write(fieldGroup.Count()); |
| | | foreach (var field in fieldGroup) |
| | | { |
| | | writer.Write(field.Name); |
| | | writer.Write(GetCecilTypeName(field.FieldType)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | static void writeProperties(BinaryWriter writer, List<PropertyInfo> properties) |
| | | { |
| | | var PropertyGroups = properties.GroupBy(m => m.DeclaringType).ToList(); |
| | | writer.Write(PropertyGroups.Count); |
| | | foreach (var PropertyGroup in PropertyGroups) |
| | | { |
| | | writer.Write(GetCecilTypeName(PropertyGroup.Key)); |
| | | writer.Write(PropertyGroup.Count()); |
| | | foreach (var Property in PropertyGroup) |
| | | { |
| | | writer.Write(Property.Name); |
| | | writer.Write(GetCecilTypeName(Property.PropertyType)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | static void writeClasses(BinaryWriter writer, List<Type> classes) |
| | | { |
| | | writer.Write(classes.Count); |
| | |
| | | /// <param name="corePath">IFix.Core.dll所在路径</param> |
| | | /// <param name="patchPath">生成的patch的保存路径</param> |
| | | public static void GenPatch(string assembly, string assemblyCSharpPath |
| | | = "./Library/ScriptAssemblies/Assembly-CSharp.dll", |
| | | = "./Library/ScriptAssemblies/Assembly-CSharp.dll", |
| | | string corePath = "./Assets/Plugins/IFix.Core.dll", string patchPath = ResourcesPath.PATCH_EDITOR) |
| | | { |
| | | var patchMethods = Configure.GetTagMethods(typeof(PatchAttribute), assembly).ToList(); |
| | |
| | | } |
| | | |
| | | var newMethods = Configure.GetTagMethods(typeof(InterpretAttribute), assembly).ToList(); |
| | | var newFields = Configure.GetTagFields(typeof(InterpretAttribute), assembly).ToList(); |
| | | var newProperties = Configure.GetTagProperties(typeof(InterpretAttribute), assembly).ToList(); |
| | | var newClasses = Configure.GetTagClasses(typeof(InterpretAttribute), assembly).ToList(); |
| | | genericMethod = newMethods.FirstOrDefault(m => hasGenericParameter(m)); |
| | | if (genericMethod != null) |
| | |
| | | { |
| | | writeMethods(writer, patchMethods); |
| | | writeMethods(writer, newMethods); |
| | | writeFields(writer, newFields); |
| | | writeProperties(writer, newProperties); |
| | | writeClasses(writer, newClasses); |
| | | } |
| | | |
| | |
| | | |
| | | foreach (var path in |
| | | (from asm in AppDomain.CurrentDomain.GetAssemblies() |
| | | select Path.GetDirectoryName(asm.ManifestModule.FullyQualifiedName)).Distinct()) |
| | | select Path.GetDirectoryName(asm.ManifestModule.FullyQualifiedName)).Distinct()) |
| | | { |
| | | try |
| | | { |
| | |
| | | { |
| | | GenPlatformPatch(Platform.android, ResourcesPath.PATCH_ANDROID); |
| | | } |
| | | catch (Exception e) |
| | | catch(Exception e) |
| | | { |
| | | UnityEngine.Debug.LogError(e); |
| | | } |
| | |
| | | { |
| | | GenPlatformPatch(Platform.ios, ResourcesPath.PATCH_IOS); |
| | | } |
| | | catch (Exception e) |
| | | catch(Exception e) |
| | | { |
| | | UnityEngine.Debug.LogError(e); |
| | | } |