最近做的项目里有个需求是这样的:对一张图片里的公式进行截图,通过调用公式识别API,获得该公式的Latex文本,通过点击按钮复制、快捷键ctrl+v粘贴。
using UnityEngine;
using UnityEngine.UI;
public class Test : MonoBehaviour
{
TextEditor te = new TextEditor();
public Text oldText;
public Text newText;
void Update()
{
if (Input.GetMouseButtonDown(0))
{
te.text = oldText.text;
//以下两行代码,相当于ctrl+c操作
te.SelectAll();
te.Copy();
}
if (Input.GetMouseButtonDown(1))
{
newText.text = te.text;
//以下代码,相当于ctrl+v操作
te.Paste();
}
}
}