Hello,
So I have a scaling canvas based on screen size that scales properly. However, I seem to be having issues with mouse position and showing elements based on mouse position. Here is my code:
public void OnPointerEnter(PointerEventData eventData)
{
StartGame gh = GameObject.FindGameObjectWithTag("GameHandler").GetComponent<StartGame>();
GameObject obj = gh.EquipmentToolTip;
RectTransform cnvs = GameObject.FindGameObjectWithTag("GameCanvas").GetComponent<RectTransform>();
obj.SetActive(true);
//get the tooltip position with offset
Vector2 offSet = new Vector2(cnvs.sizeDelta.x / 2f, cnvs.sizeDelta.y / 2f);
Vector2 viewPort = Camera.main.WorldToViewportPoint(Input.mousePosition);
Vector2 position = new Vector2(cnvs.sizeDelta.x * viewPort.x, cnvs.sizeDelta.y * viewPort.y);
obj.transform.localPosition = Vector2.Scale(position-offSet, cnvs.transform.localScale);
}
Here is the image where my tool-tip is going crazy: