Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


CreateItem

Create a new SearchItem from a value with an optional label.
Read time 3 minutesLast updated 10 days ago

Definition

CreateItem(string, Object, string)

Create a new SearchItem from a value with an optional label.
public static SearchItem CreateItem(string label, object value, string description)

Parameters

label

Optional label of the SearchItem. This will be displayed in the search Window.

value

Initial value of the SearchItem.

description

Optional description of the SearchItem. This will be displayed in the search Window.

Returns

Type

Description

SearchItemReturns a new SearchItem.

Examples

[Description("Returns asset paths corresponding to a list of instance ids")][SearchExpressionEvaluator("IdsToPaths", SearchExpressionEvaluationHints.ThreadNotSupported, SearchExpressionType.Iterable)]public static IEnumerable<SearchItem> IdsToPath(SearchExpressionContext c){ foreach (var idItem in c.args[0].Execute(c)) { if (SearchExpression.TryConvertToULong(idItem, out var idNum)) { var id = UnsafeUtility.As<ulong, EntityId>(ref idNum); var path = AssetDatabase.GetAssetPath(id); if (!string.IsNullOrEmpty(path)) { yield return SearchExpression.CreateItem(path, c.ResolveAlias("asset path")); } } }}

CreateItem(string, string)

Create a new SearchItem from a value with an optional label.
public static SearchItem CreateItem(string value, string label = null)

Parameters

value

Initial value of the SearchItem.

label

Optional label of the SearchItem. This will be displayed in the search Window.

Returns

Type

Description

SearchItemReturns a new SearchItem.

Examples

[Description("Returns asset paths corresponding to a list of instance ids")][SearchExpressionEvaluator("IdsToPaths", SearchExpressionEvaluationHints.ThreadNotSupported, SearchExpressionType.Iterable)]public static IEnumerable<SearchItem> IdsToPath(SearchExpressionContext c){ foreach (var idItem in c.args[0].Execute(c)) { if (SearchExpression.TryConvertToULong(idItem, out var idNum)) { var id = UnsafeUtility.As<ulong, EntityId>(ref idNum); var path = AssetDatabase.GetAssetPath(id); if (!string.IsNullOrEmpty(path)) { yield return SearchExpression.CreateItem(path, c.ResolveAlias("asset path")); } } }}

CreateItem(double, string)

Create a new SearchItem from a value with an optional label.
public static SearchItem CreateItem(double value, string label = null)

Parameters

value

Initial value of the SearchItem.

label

Optional label of the SearchItem. This will be displayed in the search Window.

Returns

Type

Description

SearchItemReturns a new SearchItem.

Examples

[Description("Returns asset paths corresponding to a list of instance ids")][SearchExpressionEvaluator("IdsToPaths", SearchExpressionEvaluationHints.ThreadNotSupported, SearchExpressionType.Iterable)]public static IEnumerable<SearchItem> IdsToPath(SearchExpressionContext c){ foreach (var idItem in c.args[0].Execute(c)) { if (SearchExpression.TryConvertToULong(idItem, out var idNum)) { var id = UnsafeUtility.As<ulong, EntityId>(ref idNum); var path = AssetDatabase.GetAssetPath(id); if (!string.IsNullOrEmpty(path)) { yield return SearchExpression.CreateItem(path, c.ResolveAlias("asset path")); } } }}

CreateItem(int, string)

Create a new SearchItem from a value with an optional label.
public static SearchItem CreateItem(int value, string label = null)

Parameters

value

Initial value of the SearchItem.

label

Optional label of the SearchItem. This will be displayed in the search Window.

Returns

Type

Description

SearchItemReturns a new SearchItem.

Examples

[Description("Returns asset paths corresponding to a list of instance ids")][SearchExpressionEvaluator("IdsToPaths", SearchExpressionEvaluationHints.ThreadNotSupported, SearchExpressionType.Iterable)]public static IEnumerable<SearchItem> IdsToPath(SearchExpressionContext c){ foreach (var idItem in c.args[0].Execute(c)) { if (SearchExpression.TryConvertToULong(idItem, out var idNum)) { var id = UnsafeUtility.As<ulong, EntityId>(ref idNum); var path = AssetDatabase.GetAssetPath(id); if (!string.IsNullOrEmpty(path)) { yield return SearchExpression.CreateItem(path, c.ResolveAlias("asset path")); } } }}

CreateItem(ulong, string)

Create a new SearchItem from a value with an optional label.
public static SearchItem CreateItem(ulong value, string label = null)

Parameters

value

Initial value of the SearchItem.

label

Optional label of the SearchItem. This will be displayed in the search Window.

Returns

Type

Description

SearchItemReturns a new SearchItem.

Examples

[Description("Returns asset paths corresponding to a list of instance ids")][SearchExpressionEvaluator("IdsToPaths", SearchExpressionEvaluationHints.ThreadNotSupported, SearchExpressionType.Iterable)]public static IEnumerable<SearchItem> IdsToPath(SearchExpressionContext c){ foreach (var idItem in c.args[0].Execute(c)) { if (SearchExpression.TryConvertToULong(idItem, out var idNum)) { var id = UnsafeUtility.As<ulong, EntityId>(ref idNum); var path = AssetDatabase.GetAssetPath(id); if (!string.IsNullOrEmpty(path)) { yield return SearchExpression.CreateItem(path, c.ResolveAlias("asset path")); } } }}