GUIHelper

Various helper function for GUI.

namespace Sirenix.Utilities.Editor
{
[ExtensionAttribute]
[InitializeOnLoadAttribute]
public static class GUIHelper
}

Requirements

Namespace: Sirenix.Utilities.Editor
Assembly: Sirenix.OdinInspector
Version: 2.0.0.0

Static Properties

Return Type Definition Description
float ActualLabelWidth Gets or sets the actual EditorGUIUtility.LabelWidth, regardless of the current hierarchy mode or context width.
float BetterContextWidth Odin will set this for you whenever an Odin property tree is drawn. But if you're using BetterLabelWidth and BetterContextWidth without Odin, then you need to set BetterContextWidth in the beginning of each GUIEvent.
float BetterLabelWidth Unity EditorGUIUtility.labelWidth only works reliablly in Repaint events. BetterLabelWidth does a better job at giving you the correct LabelWidth in non-repaint events.
float ContextWidth Gets the current editor gui context width. Only set these if you know what it does.
float CurrentIndentAmount Gets the current indent amount.
EditorWindow CurrentWindow Gets the current editor window.
RectOffset CurrentWindowBorderSize Gets the size of the current window border.
bool CurrentWindowHasFocus Gets a value indicating whether the current editor window is focused.
int CurrentWindowInstanceID Gets the ID of the current editor window.
Vector2 EditorScreenPointOffset Gets the editor screen point offset.
bool IsBoldLabel Gets or sets a value indicating whether labels are currently bold.
bool IsDrawingDictionaryKey Whether the inspector is currently in the progress of drawing a dictionary key.
Vector2 MouseScreenPosition Gets the mouse screen position.
bool RepaintRequested Gets a value indicating whether a repaint has been requested.

Static Methods

Return Type Definition Description
void BeginDrawToNothing() Hides the following draw calls. Remember to call EndDrawToNothing() when done.
void BeginIgnoreInput() Ignores input on following GUI calls. Remember to end with EndIgnoreInput().
void BeginLayoutMeasuring() Begins the layout measuring. Remember to end with EndLayoutMeasuring().
void ClearRepaintRequest() Clears the repaint request.
void EndDrawToNothing() Unhides the following draw calls after having called BeginDrawToNothing().
void EndIgnoreInput() Ends the ignore input started by BeginIgnoreInput().
Rect EndLayoutMeasuring() Ends the layout measuring started by BeginLayoutMeasuring()
Texture2D GetAssetThumbnail(Object, Type, bool) Gets the best thumbnail icon given the provided arguments provided.
bool GetBoldDefaultFont() Gets the bold default font.
Rect GetCurrentLayoutRect() Gets the current layout rect.
GUIStyle GetCurrentLayoutStyle() Gets the current layout rect.
Rect GetEditorWindowRect() Not yet documented.
Color GetPlaymodeTint() Gets the playmode color tint.
GUIContext<TValue> GetTemporaryContext<TValue>(Object) Gets a temporary value context.
GUIContext<TValue> GetTemporaryContext<TValue>(Object, int) Gets a temporary value context.
GUIContext<TValue> GetTemporaryContext<TValue>(Object, int, TValue) Gets a temporary context.
GUIContext<TValue> GetTemporaryContext<TValue>(Object, Object) Gets a temporary value context.
GUIContext<TValue> GetTemporaryContext<TValue>(Object, Object, TValue) Gets a temporary context.
GUIContext<TValue> GetTemporaryContext<TValue>(Object, string) Gets a temporary value context.
GUIContext<TValue> GetTemporaryContext<TValue>(Object, string, TValue) Gets a temporary context.
GUIContext<TValue> GetTemporaryContext<TValue>(Object, TValue) Gets a temporary context.
GUIContext<TValue> GetTemporaryNullableContext<TValue>(Object) Gets a temporary nullable value context.
GUIContext<TValue> GetTemporaryNullableContext<TValue>(Object, int) Gets a temporary nullable value context.
GUIContext<TValue> GetTemporaryNullableContext<TValue>(Object, Object) Gets a temporary nullable value context.
GUIContext<TValue> GetTemporaryNullableContext<TValue>(Object, string) Gets a temporary nullable value context.
Rect IndentRect(Rect) Indents the rect by the current indent amount.
void IndentRect(ref Rect) Indents the rect by the current indent amount.
bool IsDockedWindow(EditorWindow) Determines whether the specified EditorWindow is docked.
void OpenInspectorWindow(Object) Opens a new inspector window for the specified object.
void PopColor() Pops the GUI color pushed by PushColor(Color, bool).
void PopContentColor() Pops the content color pushed by PushContentColor(Color, bool).
void PopEventType() Pops the event type pushed by PopEventType().
void PopFadeGroupDuration() Pops fade group duration value pushed by PushFadeGroupDuration(float).
void PopGUIEnabled() Pops the GUI enabled pushed by PushGUIEnabled(bool)
void PopGUIPositionOffset() Pops the GUI position offset pushed by PushGUIPositionOffset(Vector2).
void PopHierarchyMode() Pops the hierarchy mode pushed by !:PushHierarchyMode(bool).
void PopIndentLevel() Pops the indent level pushed by PushIndentLevel(int).
void PopIsBoldLabel() Pops the bold label state pushed by PushIsBoldLabel(bool).
void PopIsDrawingDictionaryKey() Pops the state pushed by PushIsDrawingDictionaryKey(bool)
void PopLabelColor() Pops the label color pushed by PushLabelColor(Color).
void PopLabelWidth() Pops editor gui label widths pushed by PushLabelWidth(float).
void PopMatrix() Pops the GUI matrix pushed by PushMatrix(Matrix4x4).
void PopResponsiveVectorComponentFields() Pops responsive vector component fields value pushed by PushResponsiveVectorComponentFields(bool).
void PopTabPageSlideAnimationDuration() Pops tab page slide animation duration value pushed by PushTabPageSlideAnimationDuration(float).
void PushColor(Color, bool) Pushes a color to the GUI color stack. Remember to pop the color with PopColor().
void PushContentColor(Color, bool) Pushes the content color to the stack. Remember to pop with PopContentColor().
void PushEventType(EventType) Pushes the event type to the stack. Remember to pop with PopEventType().
void PushFadeGroupDuration(float) Pushes the value to the fade group duration stack. Remeber to pop with PopFadeGroupDuration().
void PushGUIEnabled(bool) Pushes a state to the GUI enabled stack. Remember to pop the state with PopGUIEnabled().
void PushGUIPositionOffset(Vector2) Pushes the GUI position offset to the stack. Remember to pop with PopGUIPositionOffset().
void PushHierarchyMode(bool, bool) Pushes the hierarchy mode to the stack. Remember to pop the state with PopHierarchyMode().
void PushIndentLevel(int) Pushes the indent level to the stack. Remember to pop with PopIndentLevel().
void PushIsBoldLabel(bool) Pushes bold label state to the stack. Remember to pop with PopIsBoldLabel().
void PushIsDrawingDictionaryKey(bool) Pushes a state to the IsDrawingDictionaryKey stack. Remember to pop the state with PopIsDrawingDictionaryKey().
void PushLabelColor(Color) Pushes the label color to the stack. Remember to pop with PopLabelColor().
void PushLabelWidth(float) Pushes the width to the editor GUI label width to the stack. Remmeber to Pop with PopLabelWidth().
void PushMatrix(Matrix4x4) Pushes a GUI matrix to the stack. Remember to pop with PopMatrix().
void PushResponsiveVectorComponentFields(bool) Pushes the value to the responsive vector component fields stack. Remeber to pop with PopResponsiveVectorComponentFields().
void PushTabPageSlideAnimationDuration(float) Pushes the value to the tab page slide animation duration stack. Remember to pop with PopTabPageSlideAnimationDuration().
void RemoveFocusControl() An alternative to GUI.FocusControl(null), which does not take focus away from the current GUI.Window.
void RequestRepaint() Requests a repaint.
void RequestRepaint(int) Requests a repaint.
RenderTexture TakeGUIScreenshot(Rect) Takes a screenshot of the GUI within the specified rect.
GUIContent TempContent(string) Gets a temporary GUIContent with the specified text.
GUIContent TempContent(string, string) Gets a temporary GUIContent with the specified text and tooltip.
GUIContent TempContent(string, Texture, string) Gets a temporary GUIContent with the specified text, image and tooltip.
GUIContent TempContent(Texture, string) Gets a temporary GUIContent with the specified image and tooltip.

Extension Methods

Return Type Definition Description
void RepaintIfRequested(this Editor) Repaints the editor if a repaint has been requested. If the currently rendering window is not an InspectorWindow, Repaint() will be called on the current window as well.
void RepaintIfRequested(this EditorWindow) Repaints the EditorWindow if a repaint has been requested.