Skip to content

EditorHelpers

Namespace: SideXP.Core.EditorOnly

public static class EditorHelpers

Miscellaneous functions for working in the editor context.

Methods

FocusObject(Object, bool, bool)

public static void FocusObject(Object obj, bool pingObject = true, bool selectObject = true)

Highlights and select an object. If the object is an asset, focus the project window and highlight it from project view. If it's an object in a scene, highlight it from the hierarchy.

Parameters

  • obj: The object you want to focus.
  • pingObject: Should the object be highlighted in the Project view?
  • selectObject: Should the object be selected?

FindEditorWindow(string)

public static EditorWindow FindEditorWindow(string windowTitle)

Finds an open (or loaded) EditorWindow by title.

Parameters

  • windowTitle: The title of the window to find.

Returns

Returns the found window instance.

FindEditorWindow(string, EditorWindow)

public static bool FindEditorWindow(string windowTitle, out EditorWindow window)

Finds an open (or loaded) EditorWindow by title.

Parameters

  • windowTitle: The title of the window to find.

Returns

Returns true if a window instance has been found.

FindEditorWindow(Type)

public static EditorWindow FindEditorWindow(Type windowType)

Finds an open (or loaded) EditorWindow by type.

Parameters

  • windowType: The expected type of the window to find.

Returns

Returns the found window instance.

FindEditorWindow(Type, EditorWindow)

public static bool FindEditorWindow(Type windowType, out EditorWindow window)

Finds an open (or loaded) EditorWindow by type.

Parameters

  • window: Outputs the found window instance.
  • windowType: The expected type of the window to find.

Returns

Returns true if a window instance has been found.

FindEditorWindow<T>()

public static T FindEditorWindow<T>()

Finds an open (or loaded) EditorWindow by type.

Type parameters

  • T: The expected type of the window to find.

Returns

Returns the found window instance.

FindEditorWindow<T>(T)

public static bool FindEditorWindow<T>(out T window)

Parameters

  • window: Outputs the found window instance.

Returns

Returns true if a window instance has been found.

GetLabel(Type, string, BindingFlags)

public static GUIContent GetLabel(Type type, string fieldOrPropertyName, BindingFlags bindingFlags = Instance | Public | NonPublic)

Creates a GUIContent value from the named field or property label and tooltip.

Parameters

  • type: The type of the object from which you want to get the field (or property) data.
  • fieldOrPropertyName: The name of the field (or property) of which you want to get the data.
  • bindingFlags: Filters to use for finding the field or property. By default, targets only instance data, public and non-public.

Returns

Returns the created GUIContent value.

GetLabel(Type, string, string, BindingFlags)

public static GUIContent GetLabel(Type type, string fieldOrPropertyName, string customLabel, BindingFlags bindingFlags = Instance | Public | NonPublic)

Creates a GUIContent value from the named field or property label and tooltip.

Parameters

  • type: The type of the object from which you want to get the field (or property) data.
  • fieldOrPropertyName: The name of the field (or property) of which you want to get the data.
  • customLabel: If defined, this text is used as is for the GUIContent's label.
  • bindingFlags: Filters to use for finding the field or property. By default, targets only instance data, public and non-public.

Returns

Returns the created GUIContent value.

GetLabel(object, string, BindingFlags)

public static GUIContent GetLabel(object obj, string fieldOrPropertyName, BindingFlags bindingFlags = Instance | Public | NonPublic)

Parameters

  • obj: The type of the object from which you want to get the field (or property) data.

GetLabel(object, string, string, BindingFlags)

public static GUIContent GetLabel(object obj, string fieldOrPropertyName, string customLabel, BindingFlags bindingFlags = Instance | Public | NonPublic)

Creates a GUIContent value from the named field or property label and tooltip.

Parameters

  • obj: The type of the object from which you want to get the field (or property) data.
  • fieldOrPropertyName: The name of the field (or property) of which you want to get the data.
  • customLabel: If defined, this text is used as is for the GUIContent's label.
  • bindingFlags: Filters to use for finding the field or property. By default, targets only instance data, public and non-public.

Returns

Returns the created GUIContent value.

GetLabel<T>(string, BindingFlags)

public static GUIContent GetLabel<T>(string fieldOrPropertyName, BindingFlags bindingFlags = Instance | Public | NonPublic)

Type parameters

  • T: The type of the object from which you want to get the field (or property) data.

GetLabel<T>(string, string, BindingFlags)

public static GUIContent GetLabel<T>(string fieldOrPropertyName, string customLabel, BindingFlags bindingFlags = Instance | Public | NonPublic)

Creates a GUIContent value from the named field or property label and tooltip.

Type parameters

  • T: The type of the object from which you want to get the field (or property) data.

Parameters

  • fieldOrPropertyName: The name of the field (or property) of which you want to get the data.
  • customLabel: If defined, this text is used as is for the GUIContent's label.
  • bindingFlags: Filters to use for finding the field or property. By default, targets only instance data, public and non-public.

Returns

Returns the created GUIContent value.

GetTooltip(Type, string, BindingFlags)

public static string GetTooltip(Type type, string fieldOrPropertyName, BindingFlags bindingFlags = Instance | Public | NonPublic)

Gets the tooltip of a named field or property.

Parameters

  • type: The type of the object from which you want to get the field (or property) data.
  • fieldOrPropertyName: The name of the field (or property) of which you want to get the data.
  • bindingFlags: Filters to use for finding the field or property. By default, targets only instance data, public and non-public.

Returns

Returs the found tooltip value, otherwise Empty.

GetTooltip(object, string, BindingFlags)

public static string GetTooltip(object obj, string fieldOrPropertyName, BindingFlags bindingFlags = Instance | Public | NonPublic)

Gets the tooltip of a named field or property.

Returns

Returs the found tooltip value, otherwise Empty.

GetTooltip<T>(string, BindingFlags)

public static string GetTooltip<T>(string fieldOrPropertyName, BindingFlags bindingFlags = Instance | Public | NonPublic)

Gets the tooltip of a named field or property.

Returns

Returs the found tooltip value, otherwise Empty.

TryGetActiveFolderPath(string)

public static bool TryGetActiveFolderPath(out string path)

Tries to get the active folder path from the Project view if it's open.

Parameters

  • path: Outputs the relative path to the fuond active folder.

Returns

Returns true if a path has been found.