24 lines
780 B
C#
24 lines
780 B
C#
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using System.IO;
|
|
using UnityEngine.UI;
|
|
|
|
public class DragDrop : MonoBehaviour, IDropHandler
|
|
{
|
|
private byte[] sendData; // 바이너리 데이터 저장 변수
|
|
private string fileName; // 파일 이름 저장
|
|
public void OnDrop(PointerEventData eventData)
|
|
{
|
|
if (eventData.pointerDrag != null)
|
|
{
|
|
string path = eventData.pointerDrag.GetComponent<Text>().text; // 드래그된 파일의 경로
|
|
if (File.Exists(path))
|
|
{
|
|
sendData = File.ReadAllBytes(path); // 파일을 바이너리 데이터로 저장
|
|
fileName = Path.GetFileName(path); // 파일명 저장
|
|
Debug.Log($"파일 {fileName} 로드 완료, 크기: {sendData.Length} 바이트");
|
|
}
|
|
}
|
|
}
|
|
}
|