Answer the question
In order to leave comments, you need to log in
How to check if the mouse is hovering over a button in Unity?
Hello. Maybe a stupid question, but I had it. There is a window with buttons that are created programmatically. More or less like this:
public Texture one; // Какая-то текстура
void OnGUI(){
GUI.Window (2, new Rect (Screen.width * 0.6f, 0, Screen.width * 0.4f,
Screen.height), WindowCharacterUpgrade, "");
}
void WindowCharacterUpgrade(int id){
if (GUI.Button (new Rect (((Screen.width * 0.4f) / 2) - 20, 20, 40, 40), one))
// Какое-то действие
}
Answer the question
In order to leave comments, you need to log in
Don't use OnGUI, it's old, slow and cumbersome. Use the new UI, you can start with the official tutorial or guide .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question