- Home /
Simple menu problem
Hi, I made a basic menu script using C# but I'm having an odd issue, For some reason putting a mouse over one option will color all of them.
public class HoverOver : MonoBehaviour
{
public string LevelToLoad;
public GameObject gameObject;
public bool isQuit;
void OnMouseOver()
{
gameObject.guiText.font.material.color = Color.magenta;
}
void OnMouseExit()
{
gameObject.guiText.font.material.color = Color.white;
}
void OnMouseDown()
{
Application.LoadLevel(LevelToLoad);
if (isQuit)
{
Application.Quit();
}
}
}
Answer by fafase · Dec 10, 2013 at 03:08 PM
All of your GUIText are using the same material, when you drag and drop you do not create a new material, you create a link to that material. So if you modify the material for one object, since they all refer to the same object, they all get the new value of the material.
You need a material for each GUIText so that one won't change them all.
Your answer
Follow this Question
Related Questions
adding material to unity guitext makes font turn into blocks 1 Answer
LaTeX Equations or Custom Fonts in Unity GUI and onGUI elements 1 Answer
Getting pixel perfect text with either text meshes or GUI Text on a worldspace canvas 0 Answers
Changing Gui Text on mouse over not working for black text 2 Answers
Menu button select outline. 1 Answer