I'm new to Unity and C# and have been struggling to figure out how to solve this. What I'm looking for is a way to make text display whenever a button is selected. (ex. Player selects a difficulty option, and text pops up describing what mechanics the difficulty will affect) I can get this to work with mouse input with no issue, with the following code attached to the button.
void Update() {
if (this.IsHighlighted() == true)
{
gameObject.transform.GetChild(1).gameObject.SetActive(true);
}
else
{
gameObject.transform.GetChild(1).gameObject.SetActive(false);
}
}
The aforementioned description text is set up as a child to the button, and will appear/disappear depending on whether it's highlighted or not. The problem is that isHighlighted only occurs when the mouse is hovered over the button, and does not take effect when selected via directional inputs from a keyboard/controller, which is what I'm looking for. I've done some research and noticed there is an OnSelect method, but I can't figure out how to implement it. Any advice would be greatly appreciated.
