ClipboardHelper.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using System;
  2. using System.Reflection;
  3. using UnityEngine;
  4. public class ClipboardHelper
  5. {
  6. private static PropertyInfo GetSystemCopyBufferProperty()
  7. {
  8. if (ClipboardHelper.m_systemCopyBufferProperty == null)
  9. {
  10. Type typeFromHandle = typeof(GUIUtility);
  11. ClipboardHelper.m_systemCopyBufferProperty = typeFromHandle.GetProperty("systemCopyBuffer", BindingFlags.Static | BindingFlags.NonPublic);
  12. if (ClipboardHelper.m_systemCopyBufferProperty == null)
  13. {
  14. throw new Exception("Can't access internal member 'GUIUtility.systemCopyBuffer' it may have been removed / renamed");
  15. }
  16. }
  17. return ClipboardHelper.m_systemCopyBufferProperty;
  18. }
  19. public static string clipBoard
  20. {
  21. get
  22. {
  23. PropertyInfo systemCopyBufferProperty = ClipboardHelper.GetSystemCopyBufferProperty();
  24. return (string)systemCopyBufferProperty.GetValue(null, null);
  25. }
  26. set
  27. {
  28. PropertyInfo systemCopyBufferProperty = ClipboardHelper.GetSystemCopyBufferProperty();
  29. systemCopyBufferProperty.SetValue(null, value, null);
  30. }
  31. }
  32. private static PropertyInfo m_systemCopyBufferProperty;
  33. }