- Home /
GUI Text as a Button?
I want to make a button that is just a custom font text, nothing around it. I tried creating a gui.Button and having no skin on it, adding my custom font and making it say "Play!". the problem is that in the GUISkin maker it asks for a text colour; this makes the text solid one colour, but it is a multicoloured texture font. So my question is: Is there a way to make GUI Text act as a button? Or: is there a way to make it skip the text color and leave my font the way it is?
Answer by skovacs1 · Nov 26, 2010 at 09:05 PM
Yes. To make a GUIText GameObject act as a button, you merely need to add a script with the appropriate OnMouseDown and/or OnMouseUp and/or on MouseOver and/or OnMouseExit and/or OnMouseEnter function(s) implemented for the button functionality that you desire.
No. A font merely provides information about character shapes, not about their content, so there is no "skip the text color" as the font does not contain colour information. Unity provides only one color with which to color fonts. Applying specific colours or textures to fonts is a bit more complicated a feature than Unity's GUIStyle, etc. seems to provide. Pretty much the only way to custom colour font data would be to use a GUIText GameObject or texture of your font text or several separate objects with different settings which still won't apply anything but solid colors across each object.
Feel free to roll your own GUI implementation if you like and add this functionality. Even a script that takes the text from the font and some other information and generates the textures for you might be an approach to meet your needs.
Your answer
Follow this Question
Related Questions
Display two byte character by using GUIText.(Unity iPhone) 1 Answer
Changing the font size of GUIText (on Unity iPhone)? 1 Answer
Simple way to change GUIText font size 4 Answers
How To Add Button Images To GUIText? 1 Answer
iPhone Touch Screen? 2 Answers