How would I go about adding a tooltip to a Unity UI Image?
I'm iterating through a series of List() and I'm creating a bar graph and a line graph based on those values, Later I'll replace the List with a file which it retrieves the values from. I'm having a problem though with creating a tooltip. I know how to add them to buttons created under OnGui() but that's about it. I've spent the past 2 days trying to figure this out and I'm just not sure how to go about making the bar images and dot's show up under public void OnPointerEnter(PointerEventData eventData) {} and OnPointerExit() I know that print(eventData.pointerCurrentRaycast.ToString()); will display the item I'm hovering over in the console and it seems to work fine for everything except the GameObjects that are created by my script:
private GameObject CreateBar(Vector2 graphPos, float barWidth)
{
GameObject gameObject = new GameObject("bar", typeof(Image));
gameObject.transform.SetParent(graphContainer, false);
gameObject.GetComponent<Image>().color = barColor;
RectTransform rectTransform = gameObject.GetComponent<RectTransform>();
rectTransform.anchoredPosition = new Vector2(graphPos.x, 0f);
rectTransform.sizeDelta = new Vector2(barWidth * barWidthMultiplier, graphPos.y);
rectTransform.anchorMax = new Vector2(0, 0);
rectTransform.anchorMin = new Vector2(0, 0);
rectTransform.pivot = new Vector2(.5f, 0f);
return gameObject;
}
If anyone has any suggestions I would appreciate it, I've been loosing sleep over this. It's driving me crazy. I'm just trying to make it so that when I move my mouse over a bar on the barchart or a dot on the line graph it shows me the value.