Show the tooltip when mouse over at the object

Hi, i wanted to show the tooltip like this when the mouse over at the object, here is the example image:

1434257--76484--$Capture.PNG

and

1434257--76485--$Capture2.PNG

i already tried this below code, but the message on the debug.log didn’t showed up when i am hovering my mouse to the object, the object i give the name same like this:

void Update() 
{
    Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
    RaycastHit hit;

    if (Physics.Raycast(ray,out hit)  hit.collider.gameObject.name == "Yify")
    {
        Debug.Log("Yify");
    }
}

And here is my object (i use List to multiple the objects and each object i gave the name), (The object’s name “Yify” is on the right side, dark green color):

1434257--76486--$Capture3.PNG

Please help. Thank you.

It looks like your “hit” variable isn’t being populated until the Raycast is done, so I’m not sure you can include it in the conditional logic. Try moving that logic outside of the same conditional logic that the raycast is in.

 if (Physics.Raycast(ray,out hit))
{
       if (hit.collider.gameObject.name == "Yify")
       {
            Debug.Log("Yify");
        }

  }

i already tried that one sir @jRocket, but it is cannot