- Home /
[Solved]MouseEnter not working!
When my mouse is over text, it should change it's color. I made a script (copied from the OnMouseEnter() documentation) but it just won't work. I attached a Collider to my Text.
The following code is not working: using UnityEngine; using System.Collections;
public class TextHandler : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnMouseEnter() {
renderer.material.color = Color.red;
}
}
What did I do wrong?
Answer by POLYGAMe · Feb 19, 2014 at 07:21 PM
GUITexts don't need colliders. Also, you need to be changing the font colour, not the renderer, as it's not a standard 3D object material. From the top of my head:
guiText.material.font.color = Color.red;
It's a 3d text gameobject, not GUIText. I found the problem: a collider was blocking the text!
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How do I change scene with two ui canvas text 2 Answers
Automatically resize scrollview based on vertical text length (Solved) 2 Answers