Legacy Documentation: Version 4.5.0

Script language:

  • JS
  • C#
  • Boo
Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Highlighter.Highlight

static function Highlight(windowTitle: string, text: string): bool;
static bool Highlight(string windowTitle, string text);
static def Highlight(windowTitle as string, text as string) as bool
static function Highlight(windowTitle: string, text: string, mode: HighlightSearchMode): bool;
static bool Highlight(string windowTitle, string text, HighlightSearchMode mode);
static def Highlight(windowTitle as string, text as string, mode as HighlightSearchMode) as bool

Parameters

windowTitleThe title of the window the element is inside.
textThe text to identify the element with.
modeOptional mode to specify how to search for the element.

Returns

bool false if the requested element was found; otherwise false.

Description

Highlights an element in the editor.

This function will highlight the specified element in the specified window. If the element could not be found, the function returns false. If the element is inside a scrollview and is not currently visible, the scrollview will first automatically scroll to reveal the element and then highlight it.

Once the element is highlighted it will stay highlighted until either the Highlighter.Stop function is called, or the element disappears from view. The element could disappear from view if the user scrolls away from it, the window is closed, the section of the GUI with the element in it is collapsed or otherwise hidden, or when starting or stopping Play Mode.

Most EditorGUI controls can be highlighted using their label as identifier.

// Highlight the Scale property in the Inspector.
// This will work if a GameObject is selected and shown in the Inspector,
// provided that the Transform component is not collapsed.
Highlighter.Highlight ("Inspector", "Scale");
no example available in C#
no example available in Boo

Any control that uses the SerializedProperty system can be highlighted using its SerializedProperty.propertyPath.

// Highlight the X component of the Scale property in the Inspector.
// This will work if a GameObject is selected and shown in the Inspector,
// provided that the Transform component is not collapsed.
Highlighter.Highlight ("Inspector", "m_LocalScale.x");

// If you have your own MonoBehaviour called MyBehaviour with a float called myFloat, // you can highlight that control in the Inspector like this: Highlighter.Highlight ("MyBehaviour", "myFloat");

no example available in C#
no example available in Boo

Any element with text in it can be highlighted using that text as identifier, which is for example useful for buttons.

// Highlight the Add Component button in the Inspector.
// This will work if a GameObject is selected and shown in the Inspector.
Highlighter.Highlight ("Inspector", "Add Component");

// Highlight the Create button in the Hierarchy view. Highlighter.Highlight ("Hierarchy", "Create");

no example available in C#
no example available in Boo

See the HighlightSearchMode enum for more details on identifying elements.

See Also: Highlighter.Stop, Highlighter.HighlightIdentifier.