Game Development Reference
In-Depth Information
transform.position + m_tooltipOffset;
//Activate the tooltip
TooltipItem.gameObject.SetActive(m_tooltipDisplayed);
}
public void OnPointerExit(PointerEventData eventData)
{
m_tooltipDisplayed = false;
TooltipItem.gameObject.SetActive(m_tooltipDisplayed);
}
Alternatively, in Visual Studio or MonoDevelop, you can just
right-click the interface name (for example, IPointerEnterHandler )
and navigate to Implement Interface | Implement Interface to add all
the necessary methods to your class automatically.
You just then need to add code to the generated method for what to
do when the event occurs (as shown in the previous screenshot).
It is also worth noting that in different versions of MonoDevelop and
Visual Studio, the public portion of the function may or may not be
added. Either will work, and it's up to you whether you want to expose
those functions outside of your script.
To finish, we just need to set up the properties for when the script starts by adding
the following method to the Tooltip script:
void Start () {
//Offset the tooltip above the target GameObject
m_tooltipOffset =
new Vector3(0,TooltipItem.sizeDelta.y ,0);
//Deactivate the tooltip so that it is only shown when you
//want it to
TooltipItem.gameObject.SetActive(m_tooltipDisplayed);
}
 
Search WWH ::




Custom Search