您的位置:首页 > 移动开发 > Unity3D

【Unity3d】在Unity3d中,使用C#中访问系统剪贴板

2015-06-27 14:51 621 查看
直接上代码

public static class ClipboardHelper
{
private static PropertyInfo m_systemCopyBufferProperty = null;

private static PropertyInfo GetSystemCopyBufferProperty()
{
if (m_systemCopyBufferProperty == null)
{
Type T = typeof(GUIUtility);
m_systemCopyBufferProperty = T.GetProperty("systemCopyBuffer", BindingFlags.Static | BindingFlags.NonPublic);
if (m_systemCopyBufferProperty == null)
{
throw new Exception("Can't access internal member 'GUIUtility.systemCopyBuffer' it may have been removed / renamed");
}
}

return m_systemCopyBufferProperty;
}

public static string clipBoard
{
get
{
PropertyInfo P = GetSystemCopyBufferProperty();
return (string)P.GetValue(null,null);
}

set
{
PropertyInfo P = GetSystemCopyBufferProperty();
P.SetValue(null,value,null);
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  unity unity3d 剪贴板