I just want to know when the mouse is over some buttons, to expand a window with some info text.
Is just simple, I have some canvas with empty objects full of texts, buttons, panels etc… some of this buttons have attached a script with this code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class GestorUpgrades : MonoBehaviour {
public GameObject PantalletaCost;
void OnMouseEnter()
{
Debug.Log("Enter " + gameObject.name);
}
void OnMouseOver()
{
Debug.Log("Over " + gameObject.name);
}
}
But nothing happens when mouse is over or enter them. The buttons and all the canvas hicheracy is NOT in “Ignore Raycast Layer”, and i dont know why this is happenning…
Some sugestion?
Thaanks!
Update
Hello Legend_Bacon!
Thanks for answer, i researched a little and came up with this solution.
By Inspector: Adding a EventTriger component to the button, add a “Point enter” and a “Point click” and attach the same gameobject with a script with 1 futction for each event.
public void TheNameIWant1()
{
Debug.Log("Enter " + gameObject.name);
}
public void TheNameIWant2()
{
Debug.Log("Clicked" + gameObject.name);
}
Thaanks!