HI Everybody,
I am dealing with the GUI of our game since a couple of months. We have a very large and working GUI now, but i would like to optimize it too.
The thing I am dealing with is the OnPointerEnter/Exit for the tooltips. So far i used the “ignorant” approach, that is i attached an EventTrigger to the things i wanted to have the tooltip, i was then retrieving it from the main panel script, attacking the callback from there and showing the tooltip.
SimonDarksideJ mentioned in a few different occasions that the EvenTrigger, by implementing all the events it’s an overkill in such cases, i decide therefore to go for the IPointerEnterHandler /Exit implementation, but I couldn’t find any example to get a first rough direction.
I don’t know if this approach is correct, but i wrote a little script that i then attach to the images that have to throw the tooltip. The thing is, as the tooltips will be all dynamically generated, i would like to have the control over it from the main panel script (so with a simple switch over the component hovered i can launch the tooltip script with the correct settings).
If this makes sense ( i think it does but couldn’t find any example), how do I retrieve it and use it from the main script? I mean ok, i get the TooltipSourceHandler component from the item, but how am i supposed to use it in practice? I feel a bit lost any suggestion is welcome! Cheers,
H
public class TooltipSourceHandler : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler {
#region IPointerEnterHandler implementation
public void OnPointerEnter (PointerEventData eventData)
{
Debug.Log("ENTER");
throw new System.NotImplementedException ();
}
#endregion
#region IPointerExitHandler implementation
public void OnPointerExit (PointerEventData eventData)
{
Debug.Log("EXIT");
throw new System.NotImplementedException ();
}
#endregion
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}