Simple Tooltip 에셋 무료인데 쓸만해서 사용하는 친구들 있을거임

Simple Tooltip | GUI Tools | Unity Asset Store
Use the Simple Tooltip from Norb on your next project. Find this GUI tool & more on the Unity Asset Store.
assetstore.unity.com
원래 Simple Tooltip 은 기본적으로 오른쪽 위로 툴팁이 표기되는데
아래 짤처럼 마우스가 오른쪽이나 위로 너무 가까워지면 툴팁이 잘리는 현상이 발생함.
그걸 보완하기 위해서 스크린안으로 다시 집어 넣는 코드를 추가함.
아래가 수정된 기능
STController.cs 의 UpdateShow()를 아래와 같이 변경하면됨.
private void UpdateShow()
{
if (showInFrames == -1) return;
if (showInFrames == 0) showNow = true;
if (!showNow) { showInFrames--; return; }
Vector2 mousePos = Input.mousePosition;
Vector2 tooltipSize = rect.rect.size;
float pivotX = 0f;
float pivotY = 0f;
bool IsInsideScreen(Vector2 pos, Vector2 pivot)
{
Vector2 corner = pos - Vector2.Scale(tooltipSize, pivot);
return corner.x >= 0 && corner.x + tooltipSize.x <= Screen.width
&& corner.y >= 0 && corner.y + tooltipSize.y <= Screen.height;
}
Vector2 basePivot = new Vector2(0f, 0f);
if (!IsInsideScreen(mousePos, basePivot))
{
if (mousePos.x + tooltipSize.x > Screen.width)
pivotX = 1f;
if (mousePos.y + tooltipSize.y > Screen.height)
pivotY = 1f;
if (!IsInsideScreen(mousePos, new Vector2(pivotX, pivotY)))
{
pivotX = 0f;
pivotY = 0f;
}
}
rect.pivot = new Vector2(pivotX, pivotY);
rect.anchoredPosition = mousePos;
showInFrames--;
}
{
if (showInFrames == -1) return;
if (showInFrames == 0) showNow = true;
if (!showNow) { showInFrames--; return; }
Vector2 mousePos = Input.mousePosition;
Vector2 tooltipSize = rect.rect.size;
float pivotX = 0f;
float pivotY = 0f;
bool IsInsideScreen(Vector2 pos, Vector2 pivot)
{
Vector2 corner = pos - Vector2.Scale(tooltipSize, pivot);
return corner.x >= 0 && corner.x + tooltipSize.x <= Screen.width
&& corner.y >= 0 && corner.y + tooltipSize.y <= Screen.height;
}
Vector2 basePivot = new Vector2(0f, 0f);
if (!IsInsideScreen(mousePos, basePivot))
{
if (mousePos.x + tooltipSize.x > Screen.width)
pivotX = 1f;
if (mousePos.y + tooltipSize.y > Screen.height)
pivotY = 1f;
if (!IsInsideScreen(mousePos, new Vector2(pivotX, pivotY)))
{
pivotX = 0f;
pivotY = 0f;
}
}
rect.pivot = new Vector2(pivotX, pivotY);
rect.anchoredPosition = mousePos;
showInFrames--;
}
에셋이 떡하니 있는데 프로젝트를 자기 포ㅡ폴에 써야한다고 이거 4일동안 구현했던 개발자 생각나네
버리고 가야... 에셋활용도 하나의 능력이라고 봄..나는
파는 에셋인데 그 기능이 없어?
아 무료구나. 나에게도 문해력 문제가
무료인데도 불구하고 심플 그자체라 평가 5점이더라! 써본입장에서도 굿굿이니 함써보도록~ - dc App
오 멋지다. 감사감사