- Home /
The question is answered, right answer was accepted
Get UI element under mouse
I am trying to show a little infobox that shows information about a planet when the mouse is over it. I have it display correctly but I want to get the planet number. I have this code right now:
public void ShowInfoBox(int planetNum) {
infoBox.SetActive(true);
mouseIsOver = true;
// Planet Name
Text pName = infoBox.transform.GetChild(0).GetComponent<Text>();
pName.text = "Planet Name: " + planets[planetNum].name;
}
but in the editor I can't input the planetNum.
https://gyazo.com/e46f0b284cc0a51547685dd533549155
How can I input the argument in the editor?
You have to put the object holding the component, not the script itself.
Answer by DrLlamastein · Nov 25, 2017 at 04:51 PM
Unity wasn't refreshing the inspector so the argument didn't show. When I restarted Unity the argument was there.
Follow this Question
Related Questions
Pointer Enter/Exit keeps triggering on UI element (Image) 3 Answers
Inconsistent Mouse Related Behavior in 2D 1 Answer
How to detect click on naked panel? 1 Answer
4.6 UI Image follow mouse position? 4 Answers
IPointerEnterHander only fires on click 0 Answers