Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/refactoring #6

Merged
merged 1 commit into from
Apr 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions Assets/BetterCommons/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 Assets/BetterCommons/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
Loading