- Home /
How can you do a custom GUIStyle image position?
Hello, amazing person, who is willing to help!
I am trying to customise my GUI and I have hit a wall - I can't seem to be able to position my image within a button.
(GUILayout.Button( GUIContent( text,btnTexture), GUIStyle(ImagePosition.ImageLeft), GUILayout.Width(Screen.width), GUILayout.Height(100)))
If I write ImagePosition
, I can't seem to align it to the ImageRight
, only ImageAbove
or ImageLeft
. Is it possible to change that, so I can position text to the left and image to the right?
Thank you.
Answer by MakeCodeNow · Feb 19, 2014 at 03:40 PM
You need to make a new GUIStyle of your own and the mess with the padding and the border. It should look something like this:
GUIStyle myStyle = new GUIStyle(GUI.skin.button);
myStyle.border = ...
myStyle.padding = ...
GUILayout.Button(..., myStyle);
No, unfortunately it doesn't work for me, as the image disappears, if the padding is too much. I think I will try to do two buttons ins$$anonymous$$d and just have the image on the right side button. It is a dirty way of doing it, but I just haven't found anything better so far.
Your answer
Follow this Question
Related Questions
Changing the font size of a GUI.Button in the inspector 1 Answer
Is it possible to detect which GUIStyleState is used? 2 Answers
Problems with GUI relative coordinates once the game is published for web view 1 Answer
Why is my code duplicating the name of a button? styling gui 1 Answer
NullreferenceException, BeginScrollView style change 3 Answers