Class InspectorUIUtility
This class has handy inspector UI utilities and functions.
Inheritance
InspectorUIUtility
Assembly: cs.temp.dll.dll
public static class InspectorUIUtility
Fields
Declaration
public static readonly string Astrisk
Field Value
Declaration
public static readonly string Close
Field Value
Declaration
public const int DefaultFontSize = 10
Field Value
Declaration
public const float DocLinkWidth = 175F
Field Value
Declaration
public static readonly string Down
Field Value
Declaration
public static readonly string Emoji
Field Value
Declaration
public const int HeaderFontSize = 11
Field Value
Declaration
public static readonly string Heart
Field Value
Declaration
public static readonly Texture HelpIcon
Field Value
Declaration
public static readonly Texture InfoIcon
Field Value
Declaration
public static readonly string Left
Field Value
Declaration
public static readonly string Minus
Field Value
Declaration
public static readonly string Plus
Field Value
Declaration
public static readonly string Right
Field Value
Declaration
public static readonly string Star
Field Value
Declaration
public static readonly Texture SuccessIcon
Field Value
Declaration
public const int TitleFontSize = 14
Field Value
Declaration
public static readonly string Up
Field Value
Declaration
public static readonly Texture WarningIcon
Field Value
Properties
Declaration
public static Color ColorTint10 { get; }
Property Value
Declaration
public static Color ColorTint100 { get; }
Property Value
Declaration
public static Color ColorTint25 { get; }
Property Value
Declaration
public static Color ColorTint50 { get; }
Property Value
Declaration
public static Color ColorTint75 { get; }
Property Value
Methods
adjust list settings as things change
Declaration
public static List<InspectorUIUtility.ListSettings> AdjustListSettings(List<InspectorUIUtility.ListSettings> listSettings, int count)
Parameters
Returns
Box style with left margin
Declaration
public static GUIStyle Box(int margin)
Parameters
Type |
Name |
Description |
Int32 |
margin |
|
Returns
Type |
Description |
GUIStyle |
|
Create a line across the negative space
Declaration
public static void DrawDivider()
DrawEnumSerializedProperty(Rect, SerializedProperty, GUIContent, Enum)
Draws a popup UI with PropertyField type features.
Displays prefab pending updates
Declaration
public static Enum DrawEnumSerializedProperty(Rect position, SerializedProperty prop, GUIContent label, Enum propValue)
Parameters
Type |
Name |
Description |
Rect |
position |
position to render the serialized property
|
SerializedProperty |
prop |
serialized property corresponding to Enum
|
GUIContent |
label |
label for property
|
Enum |
propValue |
Current enum value for property
|
Returns
Type |
Description |
Enum |
New enum value after draw
|
DrawEnumSerializedProperty(SerializedProperty, GUIContent, Enum)
Draws a popup UI with PropertyField type features.
Displays prefab pending updates
Declaration
public static Enum DrawEnumSerializedProperty(SerializedProperty prop, GUIContent label, Enum propValue)
Parameters
Type |
Name |
Description |
SerializedProperty |
prop |
serialized property corresponding to Enum
|
GUIContent |
label |
label for property
|
Enum |
propValue |
Current enum value for property
|
Returns
Type |
Description |
Enum |
New enum value after draw
|
draw a notice with red coloring
Declaration
public static void DrawError(string error)
Parameters
Type |
Name |
Description |
String |
error |
|
Declaration
public static void DrawHeader(string header)
Parameters
Type |
Name |
Description |
String |
header |
string content to render
|
Declaration
public static void DrawLabel(string title, int size, Color color)
Parameters
Type |
Name |
Description |
String |
title |
|
Int32 |
size |
|
Color |
color |
|
draw a notice area, normal coloring
Declaration
public static void DrawNotice(string notice)
Parameters
Type |
Name |
Description |
String |
notice |
|
Draws a section start (initiated by the Header attribute)
Declaration
public static bool DrawSectionFoldout(string headerName, bool open = true, GUIStyle style = null)
Parameters
Type |
Name |
Description |
String |
headerName |
|
Boolean |
open |
|
GUIStyle |
style |
|
Returns
Draws a section start with header name and save open/close state to given preference key in SessionState
Declaration
public static bool DrawSectionFoldoutWithKey(string headerName, string preferenceKey = null, GUIStyle style = null, bool defaultOpen = true)
Parameters
Type |
Name |
Description |
String |
headerName |
|
String |
preferenceKey |
|
GUIStyle |
style |
|
Boolean |
defaultOpen |
|
Returns
draw a notice with green coloring
Declaration
public static void DrawSuccess(string notice)
Parameters
Type |
Name |
Description |
String |
notice |
|
Declaration
public static void DrawTitle(string title)
Parameters
Type |
Name |
Description |
String |
title |
|
draw a label with a yellow coloring
Declaration
public static void DrawWarning(string warning)
Parameters
Type |
Name |
Description |
String |
warning |
|
FlexButton(GUIContent)
A button that is as wide as the label
Declaration
public static bool FlexButton(GUIContent label)
Parameters
Type |
Name |
Description |
GUIContent |
label |
content for button
|
Returns
Type |
Description |
Boolean |
true if button clicked, false otherwise
|
FlexButton(GUIContent, Int32, InspectorUIUtility.ListButtonEvent, SerializedProperty)
A button that is as wide as the label
Declaration
public static bool FlexButton(GUIContent label, int index, InspectorUIUtility.ListButtonEvent callback, SerializedProperty prop = null)
Parameters
Returns
FlexButton(GUIContent, Int32[], InspectorUIUtility.MultiListButtonEvent, SerializedProperty)
A button that is as wide as the label
Declaration
public static bool FlexButton(GUIContent label, int[] indexArr, InspectorUIUtility.MultiListButtonEvent callback, SerializedProperty prop = null)
Parameters
Returns
Type |
Description |
Boolean |
true if button clicked, false otherwise
|
FullWidthButton(GUIContent, Single, Int32, InspectorUIUtility.ListButtonEvent, SerializedProperty)
A button that is as wide as the available space
Declaration
public static bool FullWidthButton(GUIContent label, float padding, int index, InspectorUIUtility.ListButtonEvent callback, SerializedProperty prop = null)
Parameters
Returns
FullWidthButton(GUIContent, Single, Int32[], InspectorUIUtility.MultiListButtonEvent, SerializedProperty)
A button that is as wide as the available space
Declaration
public static bool FullWidthButton(GUIContent label, float padding, int[] indexArr, InspectorUIUtility.MultiListButtonEvent callback, SerializedProperty prop = null)
Parameters
Returns
Get an array of strings from a serialized list of strings, pop-up field helper
Declaration
public static string[] GetOptions(SerializedProperty options)
Parameters
Type |
Name |
Description |
SerializedProperty |
options |
|
Returns
Get the index of a serialized array item based on it's name, pop-up field helper
Declaration
public static int GetOptionsIndex(SerializedProperty options, string selection)
Parameters
Type |
Name |
Description |
SerializedProperty |
options |
|
String |
selection |
|
Returns
Help box style with left margin
Declaration
public static GUIStyle HelpBox(int margin)
Parameters
Type |
Name |
Description |
Int32 |
margin |
amount of left margin
|
Returns
Type |
Description |
GUIStyle |
Configured helpbox GUIStyle
|
Create a custom label style based on color and size
Declaration
public static GUIStyle LableStyle(int size, Color color)
Parameters
Type |
Name |
Description |
Int32 |
size |
|
Color |
color |
|
Returns
Type |
Description |
GUIStyle |
|
Render documentation button routing to relevant URI
Declaration
public static bool RenderDocumentationButton(string docURL, float width = 175F)
Parameters
Type |
Name |
Description |
String |
docURL |
documentation URL to open on button click
|
Single |
width |
|
Returns
Type |
Description |
Boolean |
true if button clicked, false otherwise
|
Render a documentation header with button for given url value
Declaration
public static bool RenderDocumentationSection(string url)
Parameters
Type |
Name |
Description |
String |
url |
Url to open if button is clicked
|
Returns
Type |
Description |
Boolean |
true if object drawn and button clicked, false otherwise
|
Render a documentation header with button if Object contains HelpURLAttribute
Declaration
public static bool RenderHelpURL(Type targetType)
Parameters
Type |
Name |
Description |
Type |
targetType |
Type to test for HelpURLAttribute
|
Returns
Type |
Description |
Boolean |
true if object drawn and button clicked, false otherwise
|
Helper function to support primary overloaded version of this functionality
Declaration
public static bool RenderIndentedButton(Func<bool> renderButton)
Parameters
Type |
Name |
Description |
Func<Boolean> |
renderButton |
The code to render button correctly based on parameter types passed
|
Returns
Type |
Description |
Boolean |
true if button clicked, false if otherwise
|
RenderIndentedButton(GUIContent, GUIStyle, GUILayoutOption[])
Helper function to render buttons correctly indented according to EditorGUI.indentLevel since GUILayout component don't respond naturally
Declaration
public static bool RenderIndentedButton(GUIContent content, GUIStyle style, params GUILayoutOption[] options)
Parameters
Type |
Name |
Description |
GUIContent |
content |
What to draw in button
|
GUIStyle |
style |
Style configuration for button
|
GUILayoutOption[] |
options |
layout options
|
Returns
Type |
Description |
Boolean |
true if button clicked, false if otherwise
|
Helper function to render buttons correctly indented according to EditorGUI.indentLevel since GUILayout component don't respond naturally
Declaration
public static bool RenderIndentedButton(string buttonText, params GUILayoutOption[] options)
Parameters
Type |
Name |
Description |
String |
buttonText |
text to place in button
|
GUILayoutOption[] |
options |
layout options
|
Returns
Type |
Description |
Boolean |
true if button clicked, false if otherwise
|
SmallButton(GUIContent)
A small button, good for a single icon like + or -
Declaration
public static bool SmallButton(GUIContent label)
Parameters
Type |
Name |
Description |
GUIContent |
label |
content to place in the button
|
Returns
Type |
Description |
Boolean |
true if button selected, false otherwise
|
SmallButton(GUIContent, Int32, InspectorUIUtility.ListButtonEvent, SerializedProperty)
A small button, good for a single icon like + or - with single index callback events
Declaration
public static bool SmallButton(GUIContent label, int index, InspectorUIUtility.ListButtonEvent callback, SerializedProperty prop = null)
Parameters
Returns
Type |
Description |
Boolean |
true if button selected, false otherwise
|
SmallButton(GUIContent, Int32[], InspectorUIUtility.MultiListButtonEvent, SerializedProperty)
A small button, good for a single icon like + or - with multi-index callback events
Declaration
public static bool SmallButton(GUIContent label, int[] indexArr, InspectorUIUtility.MultiListButtonEvent callback, SerializedProperty prop = null)
Parameters
Returns
Type |
Description |
Boolean |
true if button selected, false otherwise
|