Unity 获取系统剪切板中的内容方法(Ctrl + V)
方法1:
string str = GUIUtility.systemCopyBuffer;
Debug.Log(str);
方法2:
需要导入外部库
using System.Windows.Forms;
如何使用这个外部库,百度有很多使用方法
下面上代码
IDataObject iData = Clipboard.GetDataObject();
Debug.Log((string)iData.GetData(DataFormats.Text));
顺带附上Unity获取ctrl + V的案件监听(组合按键)
private bool keydown;
public void Update() {
if (Input.GetKeyDown(KeyCode.LeftControl)) {
keydown = true;
}
if (keydown) {
if (Input.GetKeyDown(KeyCode.V)) {
Debug.Log("ctrl + V");
keydown = false;
}
}
}
Unity 获取系统剪切板中的内容方法(Ctrl + V)
方法1:
string str = GUIUtility.systemCopyBuffer;
Debug.Log(str);
方法2:
需要导入外部库
using System.Windows.Forms;
如何使用这个外部库,百度有很多使用方法
下面上代码
IDataObject iData = Clipboard.GetDataObject();
Debug.Log((string)iData.GetData(DataFormats.Text));
顺带附上Unity获取ctrl + V的案件监听(组合按键)
private bool keydown;
public void Update() {
if (Input.GetKeyDown(KeyCode.LeftControl)) {
keydown = true;
}
if (keydown) {
if (Input.GetKeyDown(KeyCode.V)) {
Debug.Log("ctrl + V");
keydown = false;
}
}
}