17 lines
590 B
JavaScript
17 lines
590 B
JavaScript
mergeInto(LibraryManager.library, {
|
|
CopyToClipboardJS: function(text) {
|
|
// 将 Unity 中传递的 UTF8 字符串转换为 JavaScript 字符串
|
|
var copyText = UTF8ToString(text);
|
|
|
|
// 创建一个隐藏的textarea来临时存放要复制的内容
|
|
var textArea = document.createElement("textarea");
|
|
textArea.value = copyText;
|
|
document.body.appendChild(textArea);
|
|
textArea.select();
|
|
document.execCommand("copy");
|
|
document.body.removeChild(textArea);
|
|
|
|
console.log("Copied to clipboard: " + copyText);
|
|
}
|
|
});
|