Skip to content

Commit

Permalink
fix HelpBox height
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonMa0012 committed Dec 10, 2023
1 parent d363ae7 commit d0fbd0f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Editor/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,10 @@ public static void DrawHelpbox(PropertyStaticData propertyStaticData, PropertyDy
if (!string.IsNullOrEmpty(helpboxStr))
{
var content = new GUIContent(helpboxStr, _helpboxIcon);
var helpboxRect = EditorGUI.IndentedRect(EditorGUILayout.GetControlRect(true, guiStyle_Helpbox.CalcHeight(content, EditorGUIUtility.currentViewWidth)));
var textWidth = EditorGUIUtility.currentViewWidth - ReflectionHelper.EditorGUI_Indent - RevertableHelper.revertButtonWidth
- _helpboxIcon.width - guiStyle_Helpbox.margin.horizontal + 0.5f;
var textHeight = guiStyle_Helpbox.CalcHeight(new GUIContent(helpboxStr), textWidth);
var helpboxRect = EditorGUI.IndentedRect(EditorGUILayout.GetControlRect(true, textHeight));
helpboxRect.xMax -= RevertableHelper.revertButtonWidth;
GUI.Label(helpboxRect, content, guiStyle_Helpbox);
// EditorGUI.HelpBox(helpboxRect, helpboxStr, MessageType.Info);
Expand Down
11 changes: 10 additions & 1 deletion Editor/ReflectionHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,16 @@ public static void DefaultShaderPropertyInternal(MaterialEditor editor, Rect pos
EditorUtility_DisplayCustomMenuWithSeparators_Method.Invoke(null, new System.Object[] { position, options, enabled, separator, selected, callback, userData, showHotkey });
}
#endregion



#region EditorGUI

private static Type EditorGUI_Type = typeof(EditorGUI);
private static PropertyInfo EditorGUI_Indent_Property = EditorGUI_Type.GetProperty("indent", BindingFlags.NonPublic | BindingFlags.Static);

public static float EditorGUI_Indent { get { return (float)EditorGUI_Indent_Property.GetValue(null); } }

#endregion

#region MaterialEnumDrawer
// UnityEditor.MaterialEnumDrawer(string enumName)
Expand Down

0 comments on commit d0fbd0f

Please sign in to comment.