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;
}
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.