- Home /
Question by
zerophase · Dec 09, 2013 at 03:36 AM ·
guibuttonguiskinguicontent
GUIContent renders button elements different from intended
Hey, I'm trying to fill my button with a texture and place text on top of the texture. When I use GUIContent the button is resized to larger than the texture, and the text is pushed to the right of the texture. I've tried setting up a GUISSkin, but I can't seem to get the default button shape that way.
my code:
bool[] pageSelected = new bool[3]{true, false, false};
string[] buttonText = new string[3] {"Pay", "Politics", "Strike"};
private GUIContent[] navButtonContent = new GUIContent[3];
private Texture buttonArt;
void Start ()
{
buttonArt = Resources.Load<Texture>("ViewButtons");
for (int i = 0; i < navButtonContent.Length; i++)
{
navButtonContent[i] = new GUIContent(buttonText[i], buttonArt);
}
}
void OnGUI()
{
GUILayout.BeginArea(new Rect(25 * x, 450 * y, 300, 300));
for (int i = 0; i < 3; i++)
{
GUILayout.BeginVertical();
if (i > 0)
{
GUILayout.Space(25);
}
GUILayout.BeginHorizontal();
GUILayout.Space(50 * i);
if(GUILayout.Toggle(pageSelected[i], navButtonContent[i],
GUI.skin.button, GUILayout.Width(100)))
{
}
GUILayout.EndHorizontal();
GUILayout.EndVertical();
}
GUILayout.EndArea();
}
Comment
Your answer
Follow this Question
Related Questions
Whats wrong with my GUI.Toggle? 2 Answers
How to attach GUI Skin on button? 0 Answers
GUISkin is overlaying my button image 0 Answers
gui button custom skin not applying background 2 Answers
Problem with icon in GUISkin 0 Answers