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