Files
EnglewoodLAB/Assets/Sample/CursorManagerSample.cs
2026-03-10 11:35:30 +09:00

79 lines
2.8 KiB
C#

using UnityEngine;
using UVC.Util;
/// <summary>
/// CursorManager의 커서 종류별 샘플을 보여주는 테스트 클래스입니다.
/// </summary>
public class CursorManagerSample : MonoBehaviour
{
[Header("GUI Settings")]
[SerializeField] private int _buttonWidth = 150;
[SerializeField] private int _buttonHeight = 30;
[SerializeField] private int _padding = 10;
[SerializeField] private CursorManager _cursorManager;
private CursorType _currentCursorType = CursorType.Default;
private void OnGUI()
{
GUILayout.BeginArea(new Rect(_padding, _padding, _buttonWidth + _padding * 2, Screen.height - _padding * 2));
GUILayout.BeginVertical("box");
GUILayout.Label("Cursor Manager Sample", GUI.skin.box);
GUILayout.Space(10);
GUILayout.Label($"Current: {_currentCursorType}");
GUILayout.Space(10);
// 모든 CursorType에 대해 버튼 생성
foreach (CursorType cursorType in System.Enum.GetValues(typeof(CursorType)))
{
string buttonLabel = GetCursorTypeDescription(cursorType);
if (GUILayout.Button(buttonLabel, GUILayout.Width(_buttonWidth), GUILayout.Height(_buttonHeight)))
{
SetCursor(cursorType);
}
}
GUILayout.EndVertical();
GUILayout.EndArea();
}
private void SetCursor(CursorType cursorType)
{
_currentCursorType = cursorType;
_cursorManager.SetCursor(cursorType);
}
/// <summary>
/// 커서 타입에 대한 설명을 반환합니다.
/// </summary>
private string GetCursorTypeDescription(CursorType type)
{
return type switch
{
CursorType.Default => "Default (기본)",
CursorType.ResizeCol => "ResizeCol (열 조절)",
CursorType.ResizeRow => "ResizeRow (행 조절)",
CursorType.ResizeH => "ResizeH (수평 조절)",
CursorType.ResizeV => "ResizeV (수직 조절)",
CursorType.ResizeTLBR => "ResizeTLBR (↘ 대각선)",
CursorType.ResizeTRBL => "ResizeTRBL (↙ 대각선)",
CursorType.Move => "Move (이동)",
CursorType.RotateBL => "RotateBL (회전 좌하)",
CursorType.RotateBR => "RotateBR (회전 우하)",
CursorType.RotateTL => "RotateTL (회전 좌상)",
CursorType.RotateTR => "RotateTR (회전 우상)",
CursorType.Scale => "Scale (스케일)",
CursorType.Wait => "Wait (대기)",
CursorType.HandPoint => "HandPoint (손가락)",
CursorType.HandGrab => "HandGrab (꽉쥔 손)",
CursorType.Hand => "Hand (손)",
CursorType.ZoomIn => "ZoomIn (확대)",
CursorType.ZoomOut => "ZoomOut (축소)",
_ => type.ToString()
};
}
}