How to make text appear only when over button(highlighted)

In the new unity u can simply changer intractable button colors with standard text. I want to make the text only appear with the button image in being hovered over my cursor or mouse. This is what I have so far …

public class ShowText : MonoBehaviour {

public class theText = GameObject.GUIText;

void function OnMouseOver()
{

	theText = ImagePosition.TextOnly;
}

void function OnMouseExit()
{
	theText = ImagePosition.TextOnly;
}

}

Thank You,

In the new UI you can do what you are after.

Create a button object, the text should be a child of it. Then use the interface from http://docs.unity3d.com/ScriptReference/UI.Button.html

public class ButtonControl, IPointerEnterHandler, IPointerExitHandler 
{
    private GameObject childText = null; //  or make public and drag
    void Start(){
       Text text= GetComponentInChildren<Text>();
       if (text != null) 
       {
           childText = text.gameObject;
           childText.SetActive(false);
       }
    }
    public void OnPointerEnter(EventSystems.PointerEventData eventData)
    {
        childText.SetActive(true);
    }
    public void OnPointerExit(EventSystems.PointerEventData eventData)
    {
        childText.SetActive(false);
    }
}

I know this is a really old thread but just for anybody who is having trouble:

using UnityEngine;
using UnityEngine.EventSystems;

public class ButtonHover: MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
{
    public GameObject descText;

    void Start()
    {
        descText.SetActive(false);
    }

    public void OnPointerEnter(PointerEventData eventData)
    {
        descText.SetActive(true);
    }
    public void OnPointerExit(PointerEventData eventData)
    {
        descText.SetActive(false);
    }
}

@fafase’s method is correct, it just leaves out a few parts like using UnityEngine.EventSystems and : MonoBehaviour.

In my method, you make descText the text you want to appear, then, you just put the script on the button.

no, you just add ,IPointerEnterHandler, IPointerExitHandler at the end of : monobehavior next to the class name.

This answer is alright, i’m glad with that. And you can refer at here about education (If needed): giáo dục stem UTS - chương trình giáo dục phổ thông UTS