40 lines
844 B
C#
40 lines
844 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.EventSystems;
|
|
|
|
public class ChatText : MonoBehaviour, IPointerEnterHandler
|
|
{
|
|
[SerializeField] int sum = 0;
|
|
bool isok = false;
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
public void OnPointerEnter(PointerEventData eventData)
|
|
{
|
|
sum = 0;
|
|
isok = true;
|
|
//当鼠标光标移入该对象时触发
|
|
Debug.Log("运行鼠标移入");
|
|
}
|
|
void Update()
|
|
{
|
|
if (isok)
|
|
{
|
|
if (Input.GetMouseButtonDown(0))
|
|
{
|
|
sum++;
|
|
}
|
|
if (sum == 2)
|
|
{
|
|
isok = false;
|
|
GUIUtility.systemCopyBuffer = GetComponent<Text>().text;
|
|
Debug.Log("写入剪切板成功");
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|