CreateContext
Creates context from a list of search provider IDs.
Read time 3 minutesLast updated 8 days ago
Definition
- Type: Method
- Namespace: UnityEditor.Search
- Assembly: UnityEditor
CreateContext(IEnumerable<string>, string, SearchFlags)
Creates context from a list of search provider IDs.
public static SearchContext CreateContext(IEnumerable<string> providerIds, string searchText = "", SearchFlags flags = SearchFlags.Default)
Parameters
List of search provider IDs.
Search Query.
Options defining how the query is performed.
Returns
Type | Description |
|---|---|
| SearchContext | Returns a new SearchContext. |
Examples
using UnityEditor;using UnityEditor.Search;using UnityEngine;static class Example_SearchService_CreateContext{ [MenuItem("Examples/SearchService/CreateContext")] public static void Run() { using var searchContext = SearchService.CreateContext("scene", "camera"); using var results = SearchService.Request(searchContext, SearchFlags.Synchronous); { foreach (var label in results.Select(r => r.GetLabel(searchContext))) Debug.Log(label); } }}
CreateContext(IEnumerable<SearchProvider>, string, SearchFlags)
Creates context from a list of search provider IDs.
public static SearchContext CreateContext(IEnumerable<SearchProvider> providers, string searchText = "", SearchFlags flags = SearchFlags.Default)
Parameters
List of search providers.
Search Query.
Options defining how the query is performed.
Returns
Type | Description |
|---|---|
| SearchContext | Returns a new SearchContext. |
Examples
using UnityEditor;using UnityEditor.Search;using UnityEngine;static class Example_SearchService_CreateContext{ [MenuItem("Examples/SearchService/CreateContext")] public static void Run() { using var searchContext = SearchService.CreateContext("scene", "camera"); using var results = SearchService.Request(searchContext, SearchFlags.Synchronous); { foreach (var label in results.Select(r => r.GetLabel(searchContext))) Debug.Log(label); } }}
CreateContext(SearchProvider, string)
Creates context from a list of search provider IDs.
public static SearchContext CreateContext(SearchProvider provider, string searchText = "")
Parameters
Search provider (This search provider does not need to be active or registered).
Search Query.
Returns
Type | Description |
|---|---|
| SearchContext | Returns a new SearchContext. |
Examples
using UnityEditor;using UnityEditor.Search;using UnityEngine;static class Example_SearchService_CreateContext{ [MenuItem("Examples/SearchService/CreateContext")] public static void Run() { using var searchContext = SearchService.CreateContext("scene", "camera"); using var results = SearchService.Request(searchContext, SearchFlags.Synchronous); { foreach (var label in results.Select(r => r.GetLabel(searchContext))) Debug.Log(label); } }}
CreateContext(string, string, SearchFlags)
Creates context from a list of search provider IDs.
public static SearchContext CreateContext(string providerId, string searchText = "", SearchFlags flags = SearchFlags.Default)
Parameters
Unique search provider ID string (i.e. asset, scene, find, etc.)
Search Query.
Options defining how the query is performed.
Returns
Type | Description |
|---|---|
| SearchContext | Returns a new SearchContext. |
Examples
using UnityEditor;using UnityEditor.Search;using UnityEngine;static class Example_SearchService_CreateContext{ [MenuItem("Examples/SearchService/CreateContext")] public static void Run() { using var searchContext = SearchService.CreateContext("scene", "camera"); using var results = SearchService.Request(searchContext, SearchFlags.Synchronous); { foreach (var label in results.Select(r => r.GetLabel(searchContext))) Debug.Log(label); } }}
CreateContext(string, SearchFlags)
Creates context from a list of search provider IDs.
public static SearchContext CreateContext(string searchText, SearchFlags flags)
Parameters
Returns
Type | Description |
|---|---|
| SearchContext | Returns a new SearchContext. |
Examples
using UnityEditor;using UnityEditor.Search;using UnityEngine;static class Example_SearchService_CreateContext{ [MenuItem("Examples/SearchService/CreateContext")] public static void Run() { using var searchContext = SearchService.CreateContext("scene", "camera"); using var results = SearchService.Request(searchContext, SearchFlags.Synchronous); { foreach (var label in results.Select(r => r.GetLabel(searchContext))) Debug.Log(label); } }}
CreateContext(string)
Creates context from a list of search provider IDs.
public static SearchContext CreateContext(string searchText)
Parameters
Search Query.
Returns
Type | Description |
|---|---|
| SearchContext | Returns a new SearchContext. |
Examples
using UnityEditor;using UnityEditor.Search;using UnityEngine;static class Example_SearchService_CreateContext{ [MenuItem("Examples/SearchService/CreateContext")] public static void Run() { using var searchContext = SearchService.CreateContext("scene", "camera"); using var results = SearchService.Request(searchContext, SearchFlags.Synchronous); { foreach (var label in results.Select(r => r.GetLabel(searchContext))) Debug.Log(label); } }}