UnityLogWriter.cs 827 B

123456789101112131415161718192021222324252627282930
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Runtime.CompilerServices;
  5. using System.Text;
  6. namespace BepInEx.Logger
  7. {
  8. public class UnityLogWriter : BaseLogger
  9. {
  10. public void WriteToUnity(string value)
  11. {
  12. Console.Write(value);
  13. UnityEngine.UnityLogWriter.WriteStringToUnityLog(value);
  14. }
  15. public override void WriteLine(string value) => WriteToUnity($"{value}\r\n");
  16. public override void Write(char value) => WriteToUnity(value.ToString());
  17. public override void Write(string value) => WriteToUnity(value);
  18. }
  19. }
  20. namespace UnityEngine
  21. {
  22. internal sealed class UnityLogWriter
  23. {
  24. [MethodImpl(MethodImplOptions.InternalCall)]
  25. public static extern void WriteStringToUnityLog(string s);
  26. }
  27. }