mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-10 03:35:10 +00:00
fix tooltip with scaled window
This commit is contained in:
parent
ea978489b6
commit
a53176a1fd
2 changed files with 17 additions and 11 deletions
|
@ -25,7 +25,7 @@ namespace HeavenStudio.Editor
|
|||
{
|
||||
private Initializer Initializer;
|
||||
|
||||
[SerializeField] private Canvas MainCanvas;
|
||||
[SerializeField] public Canvas MainCanvas;
|
||||
[SerializeField] public Camera EditorCamera;
|
||||
|
||||
[SerializeField] public GameObject EditorLetterbox;
|
||||
|
|
|
@ -27,27 +27,33 @@ namespace HeavenStudio.Editor
|
|||
|
||||
private void Update()
|
||||
{
|
||||
Vector2 anchoredPosition = Input.mousePosition;
|
||||
Vector3 anchoredPosition = Input.mousePosition;
|
||||
Camera camera = Camera.main;
|
||||
Vector3 canvasScale = Editor.instance.MainCanvas.transform.localScale;
|
||||
Vector2 scale = new Vector2(canvasScale.x, canvasScale.y);
|
||||
float toolTipScale = camera.pixelWidth / 1280f;
|
||||
|
||||
if (anchoredPosition.x + background.rect.width > canvasRect.rect.width)
|
||||
if (anchoredPosition.x + background.rect.width * toolTipScale > camera.pixelWidth)
|
||||
{
|
||||
anchoredPosition.x = canvasRect.rect.width - background.rect.width;
|
||||
anchoredPosition.x = camera.pixelWidth - background.rect.width * toolTipScale;
|
||||
}
|
||||
if (anchoredPosition.x < 0)
|
||||
if (anchoredPosition.x < -camera.pixelWidth)
|
||||
{
|
||||
anchoredPosition.x = 0;
|
||||
anchoredPosition.x = -camera.pixelWidth;
|
||||
}
|
||||
|
||||
if (anchoredPosition.y + background.rect.height > canvasRect.rect.height)
|
||||
if (anchoredPosition.y + background.rect.height * toolTipScale > camera.pixelHeight)
|
||||
{
|
||||
anchoredPosition.y = canvasRect.rect.height - background.rect.height;
|
||||
anchoredPosition.y = camera.pixelHeight - background.rect.height * toolTipScale;
|
||||
}
|
||||
if (anchoredPosition.y < 0)
|
||||
if (anchoredPosition.y < -camera.pixelHeight)
|
||||
{
|
||||
anchoredPosition.y = 0;
|
||||
anchoredPosition.y = -camera.pixelHeight;
|
||||
}
|
||||
|
||||
rectTransform.anchoredPosition = anchoredPosition;
|
||||
anchoredPosition.z = camera.nearClipPlane;
|
||||
anchoredPosition = camera.ScreenToWorldPoint(anchoredPosition);
|
||||
rectTransform.anchoredPosition = anchoredPosition / scale;
|
||||
}
|
||||
|
||||
public static void OnEnter(string tooltipText, string altTooltipText)
|
||||
|
|
Loading…
Reference in a new issue