28 lines
748 B
C#
28 lines
748 B
C#
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class CopyTextButton : MonoBehaviour
|
|
{
|
|
[SerializeField] private TMP_Text textToCopy;
|
|
[SerializeField] private TMP_Text labelText;
|
|
[SerializeField] Button button;
|
|
public void Awake()
|
|
{
|
|
button.onClick.AddListener(CopyText);
|
|
}
|
|
public void CopyText()
|
|
{
|
|
GUIUtility.systemCopyBuffer = textToCopy.text;
|
|
}
|
|
public void SetText(string labeltext, string text, bool? inAddressables = null)
|
|
{
|
|
labelText.text = labeltext;
|
|
textToCopy.text = text;
|
|
if (inAddressables == null)
|
|
labelText.color = Color.white;
|
|
else
|
|
labelText.color = inAddressables.Value ? Color.green : Color.red;
|
|
}
|
|
|
|
} |