Display text text where the mouse is located

Source: Internet
Author: User

Namespaces to be added using list
Using System.Collections.Generic;

Declaring a list container with an element type of type int

Toolpic for picture-holding

Public list<gameobject> ToolPic2 = new list<gameobject> ();

Toolpicname for displaying text text

Public list<gameobject> toolpicname = new list<gameobject> ();

void Start ()
{
for (int i = 0; i < Toolpic.count; i++)
{
Eventtriggerlistener.get (Toolpic[i]). OnEnter + = Onmouseenterimage;
Eventtriggerlistener.get (Toolpic[i]). OnExit + = Onmouseexitimage;
}

}

Mouse into the picture
void Onmouseenterimage (Gameobject btn)
{
for (int i = 0; i < Toolpic.count; i++)
{

   Displays text text of the corresponding picture when the mouse passes through the picture
if (btn = = Toolpic[i])
{
Toolpicname[i]. SetActive (TRUE);
}
}
}
void Onmouseexitimage (Gameobject btn)
{

//When the mouse exits the picture, the text of the corresponding picture is hidden
for (int i = 0; i < Toolpic.count; i++)
{
if (btn = = Toolpic[i])
{
Toolpicname[i]. SetActive (FALSE);
}
}
}

Note:

Mouse over the picture to display the corresponding text text, the mouse to exit the picture when the corresponding text hidden text

* Bind the corresponding picture and text in the Insepector window

Display text text where the mouse is located

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.