Skip to content

Commit

Permalink
Merge pull request #6
Browse files Browse the repository at this point in the history
feature/refactoring
  • Loading branch information
uurha committed Apr 21, 2024
1 parent 7d6adf4 commit 69b9cc2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
31 changes: 23 additions & 8 deletions Editor/Utility/ExtendedGUIUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ public static string NotSupportedMessage(string fieldName, Type fieldType, Type
/// <param name="fieldType"></param>
/// <param name="attributeType"></param>
/// <param name="property"></param>
public static void NotSupportedAttribute(Rect position, SerializedProperty property, GUIContent label, Type fieldType, Type attributeType)
/// <param name="offset"></param>
public static void NotSupportedAttribute(Rect position, SerializedProperty property, GUIContent label, Type fieldType, Type attributeType, float offset)
{
if (property == null)
{
Expand All @@ -80,10 +81,24 @@ public static void NotSupportedAttribute(Rect position, SerializedProperty prope
return;
}

HelpBoxFromRect(position, property, label, NotSupportedMessage(property.name, fieldType, attributeType), IconType.ErrorMessage);
HelpBoxFromRect(position, property, label, NotSupportedMessage(property.name, fieldType, attributeType), IconType.ErrorMessage, offset);
}

public static void HelpBoxFromRect(Rect position, SerializedProperty property, GUIContent label, string message, IconType messageType)
/// <summary>
/// Not supported Inspector HelpBox with RTF text
/// </summary>
/// <param name="position"></param>
/// <param name="label"></param>
/// <param name="fieldType"></param>
/// <param name="attributeType"></param>
/// <param name="property"></param>
public static void NotSupportedAttribute(Rect position, SerializedProperty property, GUIContent label, Type fieldType, Type attributeType)
{
var offset = EditorGUI.GetPropertyHeight(property, label, true) + SpaceHeight;
NotSupportedAttribute(position, property, label, fieldType, attributeType, offset);
}

public static void HelpBoxFromRect(Rect position, SerializedProperty property, GUIContent label, string message, IconType messageType, float offset = 0)
{
if (property == null)
{
Expand All @@ -101,7 +116,7 @@ public static void HelpBoxFromRect(Rect position, SerializedProperty property, G

var lab = new GUIContent(label);

buffer.y += EditorGUI.GetPropertyHeight(property, label, true) + SpaceHeight;
buffer.y += offset;

label.image = lab.image;
label.text = lab.text;
Expand Down Expand Up @@ -200,15 +215,15 @@ public static void HelpBox(Rect position, GUIContent message)
public static float GetHelpBoxHeight(float width, string message, IconType type)
{
var icon = type.GetIconName();
var withIcon = UnityEditor.EditorGUIUtility.TrTextContentWithIcon(message, icon);
var withIcon = EditorGUIUtility.TrTextContentWithIcon(message, icon);
return CreateOrReturnHelpBoxStyle().CalcHeight(withIcon, width);
}

public static float GetHelpBoxHeight(string message, IconType type)
{
var icon = type.GetIconName();
var withIcon = UnityEditor.EditorGUIUtility.TrTextContentWithIcon(message, icon);
return CreateOrReturnHelpBoxStyle().CalcHeight(withIcon, UnityEditor.EditorGUIUtility.currentViewWidth);
var withIcon = EditorGUIUtility.TrTextContentWithIcon(message, icon);
return CreateOrReturnHelpBoxStyle().CalcHeight(withIcon, EditorGUIUtility.currentViewWidth);
}

public static float GetHelpBoxHeight(GUIContent message)
Expand All @@ -219,7 +234,7 @@ public static float GetHelpBoxHeight(GUIContent message)
return 0;
}

return CreateOrReturnHelpBoxStyle().CalcHeight(message, UnityEditor.EditorGUIUtility.currentViewWidth);
return CreateOrReturnHelpBoxStyle().CalcHeight(message, EditorGUIUtility.currentViewWidth);
}

public static float GetHelpBoxHeight(string message)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "com.tdw.better.commons",
"displayName": "Better Commons",
"version": "0.0.2",
"version": "0.0.3",
"unity": "2021.3",
"description": " ",
"dependencies": {
Expand Down

0 comments on commit 69b9cc2

Please sign in to comment.