Would it be possible to get an explanation for this function? This seems to be the most complicated part of code for this section for me, and it would be great to understand it.
private void PositionTooltip()
{
// Required to ensure corners are updated by positioning elements.
Canvas.ForceUpdateCanvases();
var tooltipCorners = new Vector3[4];
tooltip.GetComponent<RectTransform>().GetWorldCorners(tooltipCorners);
var slotCorners = new Vector3[4];
GetComponent<RectTransform>().GetWorldCorners(slotCorners);
bool below = transform.position.y > Screen.height / 2;
bool right = transform.position.x < Screen.width / 2;
int slotCorner = GetCornerIndex(below, right);
int tooltipCorner = GetCornerIndex(!below, !right);
tooltip.transform.position = slotCorners[slotCorner] - tooltipCorners[tooltipCorner] + tooltip.transform.position;
}