EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField("",style,GUILayout.Width(15),GUILayout.Height(15));
EditorGUILayout.BeginHorizontal(helpbox);
EditorGUILayout.LabelField(error,style,GUILayout.Width(15),GUILayout.Height(15));
EditorGUILayout.LabelField("","Make sure the tool handle is placed at the active object's pivot point.");
EditorGUILayout.EndHorizontal();
EditorGUILayout.EndHorizontal();
that gives me this:
But as you can see, the red icon is not centered in the box, how would I change this?
the variable ‘error’ is defined like this:
GUIContent error = new GUIContent();
error = EditorGUIUtility.IconContent("CollabConflict");
static class Styles {
internal static GUIContent PivotError;
internal static GUIContent DoorError;
internal static GUIContent AngleError;
internal static GUIContent SpeedError;
internal static GUIStyle helpbox;
static Styles()
{
PivotError = EditorGUIUtility.IconContent("CollabConflict");
PivotError.text = " Make sure the tool handle is placed at the active object's pivot point.";
DoorError = EditorGUIUtility.IconContent("CollabConflict");
DoorError.text = " If your door is not scaled in Unity3D units and the pivot position is not already positioned correctly, the hinge algorithm will not work as expected.";
AngleError = EditorGUIUtility.IconContent("CollabConflict");
AngleError.text = " The difference between FinalAngle and InitialAngle should be less than 360°.";
SpeedError = EditorGUIUtility.IconContent("CollabConflict");
SpeedError.text = " The speed of a rotation block should be higher than zero.";
helpbox = new GUIStyle(EditorStyles.helpBox);
helpbox.alignment = TextAnchor.MiddleLeft;
}
}
And then when I want to put a label on the screen like this:
Ah yeah sorry, IconContent returns a cached GUIContent when possible. I’d make a simple wrapper function for it:
static Styles() {
PivotError = IconContent("CollabConflict", " Make sure the tool handle is placed at the active object's pivot point.");
DoorError = IconContent("CollabConflict", " If your door is not scaled in Unity3D units and the pivot position is not already positioned correctly, the hinge algorithm will not work as expected.");
AngleError = IconContent("CollabConflict", " The difference between FinalAngle and InitialAngle should be less than 360°.");
SpeedError = IconContent("CollabConflict", " The speed of a rotation block should be higher than zero.");
helpbox = new GUIStyle(EditorStyles.helpBox);
helpbox.alignment = TextAnchor.MiddleLeft;
}
static GUIContent IconContent(string icon, string text) {
GUIContent cached = EditorGUIUtility.IconContent(icon);
return new GUIContent(text, cached.image);
}