I am trying to write a script to display a tooltip, but I get this error… I cant use the inspector OnPointerEnter because I am using a drag and drop implementation, and one blocks the other… Any ideas what am i doing wrong?
NullReferenceException: Object
reference not set to an instance of an
object
UnityStandardAssets.Characters.FirstPerson.DragDrop.TooltipOn
() (at Assets/Scripts/DragDrop.cs:73)
UnityStandardAssets.Characters.FirstPerson.DragDrop.Update
() (at Assets/Scripts/DragDrop.cs:56)
This is my code…
private Rect currentRect;
void Start () {
currentRect = gameObject.GetComponent<RectTransform>().rect;
}
void Update(){
TooltipOn();
}
public void TooltipOn()//if the mouse is over the icon draw tool tip
{
if (currentRect.Contains(Event.current.mousePosition))
{
Debug.Log("I am here");
}
}