using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UVC.Core;
namespace UVC.Util
{
///
/// 커서의 모양을 관리하는 싱글톤 클래스입니다.
///
public class CursorManager : SingletonScene
{
///
/// 커서 유형별 텍스처와 핫스팟 정보를 담는 구조체입니다.
///
[System.Serializable]
public struct CursorData
{
public CursorType type;
public Texture2D texture;
public Vector2 hotspot;
}
[Header("Cursor Settings")]
[Tooltip("각 커서 유형에 맞는 텍스처와 핫스팟을 설정합니다.")]
[SerializeField]
private List _cursorDataList = new List();
private Dictionary _cursorDataDict;
///
/// 초기화 시점에 리스트를 딕셔너리로 변환하여 빠른 조회를 가능하게 합니다.
///
protected override void Init()
{
base.Init();
_cursorDataDict = _cursorDataList.ToDictionary(data => data.type);
}
///
/// 지정된 유형으로 커서를 변경합니다.
///
/// 변경할 커서의 유형
public void SetCursor(CursorType type)
{
if (type == CursorType.Default)
{
// 기본 커서로 설정
Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
return;
}
if (_cursorDataDict.TryGetValue(type, out CursorData data))
{
if (data.texture != null)
{
Cursor.SetCursor(data.texture, data.hotspot, CursorMode.Auto);
}
else
{
Debug.LogWarning($"CursorManager: '{type}'에 대한 텍스처가 설정되지 않았습니다.");
}
}
else
{
Debug.LogWarning($"CursorManager: '{type}'에 대한 커서 데이터가 없습니다.");
}
}
///
/// 커서를 시스템 기본값으로 되돌립니다.
///
public void SetDefaultCursor()
{
SetCursor(CursorType.Default);
}
}
///
/// CursorManager에서 사용할 커서 유형을 정의합니다.
///
public enum CursorType
{
///
/// 시스템 기본 커서
///
Default,
///
/// 수직 Column 조절 커서
///
ResizeCol,
///
/// 수평 Row 조절 커서
///
ResizeRow,
///
/// 수평 크기 조절 커서
///
ResizeH,
///
/// 수직 크기 조절 커서
///
ResizeV,
///
/// 좌상우하 대각선 크기 조절 커서
///
ResizeTLBR,
///
/// 우상좌하 대각선 크기 조절 커서
///
ResizeTRBL,
///
/// 이동 커서
///
Move,
///
/// 회전 bottom left 커서
///
RotateBL,
///
/// 회전 bottom right 커서
///
RotateBR,
///
/// 회전 top left 커서
///
RotateTL,
///
/// 회전 top right 커서
///
RotateTR,
///
/// 스케일 조절 커서
///
Scale,
///
/// 대기 상태 커서
///
Wait,
///
/// 검지 펼친 손 상태 커서
///
HandPoint,
///
/// 꽉쥔 손 상태 커서
///
HandGrab,
///
/// 손 모양 커서
///
Hand,
///
/// Zoom in 커서
///
ZoomIn,
///
/// Zoom out 커서
///
ZoomOut,
Node,
Link,
Arc
}
}