56 lines
1.6 KiB
C#
56 lines
1.6 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using TMPro;
|
|
using UnityEngine.EventSystems;
|
|
using static MainCanvasManager;
|
|
|
|
public class MediaViewerItem : MonoBehaviour, IPointerClickHandler
|
|
{
|
|
public Button copy_button;
|
|
public TextMeshProUGUI file_name_text;
|
|
public string file_path;
|
|
public string file_type;
|
|
public string perfer_str;
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
copy_button.onClick.AddListener(OnCopy);
|
|
}
|
|
|
|
private void OnCopy()
|
|
{
|
|
CancelInvoke("OnButtonClick");
|
|
GUIUtility.systemCopyBuffer = file_name_text.text;
|
|
copy_button.targetGraphic.color = Color.gray;
|
|
Invoke("OnButtonClick", 0.1f);
|
|
}
|
|
|
|
public void Init(string _file_type,string _file_name, string _path)
|
|
{
|
|
file_name_text.text = _file_name;
|
|
file_path = _path;
|
|
file_type = _file_type;
|
|
|
|
perfer_str = string.Format("{0}/*/{1}/*/{2}", _file_type, _file_name, _path);
|
|
}
|
|
|
|
private void OnButtonClick()
|
|
{
|
|
copy_button.targetGraphic.color = Color.white;
|
|
}
|
|
|
|
public void OnPointerClick(PointerEventData eventData)
|
|
{
|
|
if (eventData.button == PointerEventData.InputButton.Right)
|
|
{
|
|
media_viwer_panel.current_media_item = this;
|
|
media_viwer_panel.context_menu_image.gameObject.SetActive(true);
|
|
var __pos = new Vector2(eventData.position.x, -(MainCanvas.rect.height - eventData.position.y));
|
|
media_viwer_panel.context_menu_image.anchoredPosition = __pos;
|
|
}
|
|
}
|
|
}
|