Unity3D/Script

ClipboardHelper

blueasa 2014. 5. 15. 02:08

출처 : http://answers.unity3d.com/questions/266244/how-can-i-add-copypaste-clipboard-support-to-my-ga.html



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


반응형