有人能帮我吗?我看到一些代码,他们真的很难理解,我也是一个初学者在Unity和C#。如何复制到剪贴板文本?有没有任何资产可能有帮助?
polkgigr1#
简单的方法是:
GUIUtility.systemCopyBuffer = "the text you want to copy";
不知道Android是否支持。
xxslljrj2#
你可以试试这样
void CopyToClipboard(string str) { TextEditor textEditor = new TextEditor(); textEditor.text = str; textEditor.SelectAll(); textEditor.Copy(); } //Calling the method CopyToClipboard("Hello World");
h43kikqp3#
您应该使用UniClipboard资产。将其导入到您的项目中,然后调用:
UniClipboard.SetText("text you want to copy");
如果您需要从剪贴板获取文本:
string text = UniClipboard.GetText();
mbjcgjjk4#
你可以在Unity上尝试使用UniClipboard插件来使用依赖于操作系统的剪贴板。这是在所有平台上使用一行简单代码的工作。它具有与iOS,Android OS和Unity Editor的简单界面。
插件链接:-UniClipboard Plugin
scyqe7ek5#
我不是很熟悉Android,但在Unity中复制文本是这样做的:
private void CopyText(string textToCopy) { TextEditor editor = new TextEditor { text = textToCopy }; editor.SelectAll(); editor.Copy(); }
只要从任何地方调用该函数,您就可以在剪贴板中获得文本。但给你个建议也许你想在你一头扎进移动的开发之前,先尝试一下C#/Unity的基础知识,这对初学者来说并不友好。祝你好运!
5条答案
按热度按时间polkgigr1#
简单的方法是:
不知道Android是否支持。
xxslljrj2#
你可以试试这样
h43kikqp3#
您应该使用UniClipboard资产。
将其导入到您的项目中,然后调用:
如果您需要从剪贴板获取文本:
mbjcgjjk4#
你可以在Unity上尝试使用UniClipboard插件来使用依赖于操作系统的剪贴板。
这是在所有平台上使用一行简单代码的工作。
它具有与iOS,Android OS和Unity Editor的简单界面。
插件链接:-UniClipboard Plugin
scyqe7ek5#
我不是很熟悉Android,但在Unity中复制文本是这样做的:
只要从任何地方调用该函数,您就可以在剪贴板中获得文本。
但给你个建议也许你想在你一头扎进移动的开发之前,先尝试一下C#/Unity的基础知识,这对初学者来说并不友好。
祝你好运!