Merge pull request '커서 아이콘이 초기화 되지 않는 버그 수정' (#3) from sjm/250224 into main
Reviewed-on: http://220.90.135.190:3000/UVCXR/Studio/pulls/3
This commit was merged in pull request #3.
This commit is contained in:
@@ -53,6 +53,8 @@ namespace XED.UI
|
||||
[SerializeField]
|
||||
Texture2D cursor_DownRight;
|
||||
|
||||
Vector2 mousePos;
|
||||
|
||||
Direction direction;
|
||||
|
||||
Vector2 initialMousePos;
|
||||
@@ -78,31 +80,34 @@ namespace XED.UI
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
state = GUIState.None;
|
||||
InitializeState();
|
||||
transform.SetAsLastSibling();
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
InitializeState();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
bool mouseDown = Input.GetMouseButtonDown(0);
|
||||
bool mouseUp = Input.GetMouseButtonUp(0);
|
||||
Vector2 mousePos = Input.mousePosition;
|
||||
mousePos = Input.mousePosition;
|
||||
|
||||
if (mouseUp)
|
||||
{
|
||||
state = GUIState.None;
|
||||
SetPanelPivot(initialPivot);
|
||||
InitializeState();
|
||||
}
|
||||
|
||||
ChangeMouseCursor(mousePos);
|
||||
ChangeMouseCursor();
|
||||
|
||||
Direction handleDirection = GetHandleDirection(mousePos);
|
||||
Direction handleDirection = GetHandleDirection();
|
||||
if (mouseDown && handleDirection != Direction.None)
|
||||
{
|
||||
SetResizeState(handleDirection);
|
||||
}
|
||||
|
||||
if (mouseDown && IsHeaderRange(mousePos))
|
||||
else if (mouseDown && IsRectContainsMouse(header))
|
||||
{
|
||||
SetMoveState();
|
||||
}
|
||||
@@ -118,18 +123,18 @@ namespace XED.UI
|
||||
}
|
||||
}
|
||||
|
||||
bool IsHeaderRange(Vector2 pos)
|
||||
bool IsRectContainsMouse(RectTransform range)
|
||||
{
|
||||
Vector2 localPoint;
|
||||
RectTransformUtility.ScreenPointToLocalPointInRectangle(header, pos, null, out localPoint);
|
||||
RectTransformUtility.ScreenPointToLocalPointInRectangle(range, mousePos, null, out localPoint);
|
||||
|
||||
return header.rect.Contains(localPoint);
|
||||
}
|
||||
|
||||
Direction GetHandleDirection(Vector2 pos)
|
||||
Direction GetHandleDirection()
|
||||
{
|
||||
Vector2 localPoint;
|
||||
RectTransformUtility.ScreenPointToLocalPointInRectangle(rect, pos, null, out localPoint);
|
||||
RectTransformUtility.ScreenPointToLocalPointInRectangle(rect, mousePos, null, out localPoint);
|
||||
|
||||
if (!rect.rect.Contains(localPoint)) return Direction.None;
|
||||
|
||||
@@ -279,12 +284,12 @@ namespace XED.UI
|
||||
rect.localPosition -= deltaPosition;
|
||||
}
|
||||
|
||||
public void ChangeMouseCursor(Vector2 pos)
|
||||
public void ChangeMouseCursor()
|
||||
{
|
||||
if (state == GUIState.Resize)
|
||||
return;
|
||||
|
||||
switch (GetHandleDirection(pos))
|
||||
switch (GetHandleDirection())
|
||||
{
|
||||
case Direction.Up:
|
||||
ChangeCursor(cursor_Up);
|
||||
@@ -327,5 +332,12 @@ namespace XED.UI
|
||||
|
||||
Cursor.SetCursor(cursorTexture, hotspot, CursorMode.Auto);
|
||||
}
|
||||
|
||||
void InitializeState()
|
||||
{
|
||||
state = GUIState.None;
|
||||
SetPanelPivot(initialPivot);
|
||||
ChangeCursor(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user