private static ISupportModule Initialize() { LogSupport.RemoveAllHandlers(); if (CumConsole.Enabled || Imports.IsDebugMode()) { LogSupport.InfoHandler += CumLogger.Log; } LogSupport.WarningHandler += CumLogger.LogWarning; LogSupport.ErrorHandler += CumLogger.LogError; if (Imports.IsDebugMode()) { LogSupport.TraceHandler += CumLogger.Log; } ClassInjector.DoHook += Imports.Hook; GetUnityVersionNumbers(out var major, out var minor, out var patch); UnityVersionHandler.Initialize(major, minor, patch); // Il2CppSystem.Console.SetOut(new Il2CppSystem.IO.StreamWriter(Il2CppSystem.IO.Stream.Null)); try { var il2CppSystemAssembly = Assembly.Load("Il2Cppmscorlib"); var consoleType = il2CppSystemAssembly.GetType("Il2CppSystem.Console"); var streamWriterType = il2CppSystemAssembly.GetType("Il2CppSystem.IO.StreamWriter"); var streamType = il2CppSystemAssembly.GetType("Il2CppSystem.IO.Stream"); var setOutMethod = consoleType.GetMethod("SetOut", BindingFlags.Static | BindingFlags.Public); var nullStreamField = streamType.GetProperty("Null", BindingFlags.Static | BindingFlags.Public).GetGetMethod(); var streamWriterCtor = streamWriterType.GetConstructor(new[] { streamType }); var nullStream = nullStreamField.Invoke(null, new object[0]); var steamWriter = streamWriterCtor.Invoke(new[] { nullStream }); setOutMethod.Invoke(null, new[] { steamWriter }); } catch (Exception ex) { CumLogger.LogError($"Console cleaning failed: {ex}"); } SetAsLastSiblingDelegateField = IL2CPP.ResolveICall <SetAsLastSiblingDelegate>("UnityEngine.Transform::SetAsLastSibling"); ClassInjector.RegisterTypeInIl2Cpp <CumLoaderComponent>(); CumLoaderComponent.Create(); SceneManager.sceneLoaded = ( (SceneManager.sceneLoaded == null) ? new Action <Scene, LoadSceneMode>(OnSceneLoad) : Il2CppSystem.Delegate.Combine(SceneManager.sceneLoaded, (UnityAction <Scene, LoadSceneMode>) new Action <Scene, LoadSceneMode>(OnSceneLoad)).Cast <UnityAction <Scene, LoadSceneMode> >() ); Camera.onPostRender = ( (Camera.onPostRender == null) ? new Action <Camera>(OnPostRender) : Il2CppSystem.Delegate.Combine(Camera.onPostRender, (Camera.CameraCallback) new Action <Camera>(OnPostRender)).Cast <Camera.CameraCallback>() ); return(new Module()); }
public void Destroy() => CumLoaderComponent.Destroy();
private static ISupportModule Initialize() { CumLoaderComponent.Create(); return(new Module()); }