Hai, i already have this player on my screen. And i want, whenever the mouse hover at the object, the GUI button show itself (like tooltip). I tried below code, but the button is not showed up when i hover at the object. Here is my code:
void OnMouseEnter()
{
Rect buttonRect = new Rect(250, Screen.height - buttonHeight, textInfoPlayerButtonWidth, textInfoPlayerButtonHeight);
if (GameManager.instance.currentPlayerIndex == 0) (the object)
{
if (GUI.Button(buttonRect, "This is player 1"))
{
}
}
}
I want to be it like this:
But i want it to be show that GUI hovering button on that character, not when the character selected.
I think it has to be in an OnGUI function to show up… you could make a boolean that’s triggered on or off when mouse enter/exit that then throws the button in the OnGUI function. Correct me if I’m wrong, I’m pretty new to this
GUI functions only show within OnGUI. The best way to do that is to add a piece of code that only shows the button when a bool is true and set that bool using OnMouseEnter and OnMouseExit.
so, what do i have to do mr @smalldragon979? could you give me some example based on my question? so, when hovering the mouse to the object, the GUI showed up. Thank you very much