Search Unity

Positioning the image right of the text instead of left in GUIContent.

Discussion in 'Immediate Mode GUI (IMGUI)' started by alexanderameye, Dec 5, 2017.

  1. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Hey!

    So I have a GUIContent that I draw in my editor UI with this code.

    Code (CSharp):
    1. public static class Styles
    2.     {
    3.         internal static GUIStyle helpButton;
    4.         internal static GUIContent help;
    5.    
    6.         static Styles()
    7.         {
    8.             help = IconContent("V1.1.0", "help", "Help.");
    9.  
    10.             helpButton = new GUIStyle()
    11.             {
    12.                alignment = TextAnchor.MiddleRight,
    13.                fontStyle = FontStyle.Bold
    14.             };
    15.         }
    16.  
    17.         static GUIContent IconContent(string text, string icon, string tooltip)
    18.         {
    19.             GUIContent cached = EditorGUIUtility.IconContent(icon);
    20.             return new GUIContent(text, cached.image, tooltip);
    21.         }
    22.     }
    and then doing

    Code (CSharp):
    1. if(GUILayout.Button(Styles.help, Styles.helpButton))
    So this draws the GUIContent like this.



    My question is, is there a way to draw the image right of the text instead of left of it?

    Alex

    Update: So I've found this but I'm still not sure how to position the image right of the text.

    Update: I've found this on UA but it doesn't seem to be really answered..
     
    Last edited: Dec 5, 2017