Version: 2023.2
언어: 한국어

SearchEngineScope

enumeration

매뉴얼로 전환

설명

An enumeration that contains the available search engine scopes.

A search engine scope identifies where a search comes from. This is useful when implementing a single entry point for the base engine functions:

using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEditor.SearchService;

class BaseEngine : ISearchEngineBase
{
    public virtual void BeginSession(ISearchContext context)
    {
        if (context.engineScope == ObjectSelectorSearch.EngineScope || context.engineScope == ProjectSearch.EngineScope)
        {
            // Cache Assets.
        }
        if (context.engineScope == ObjectSelectorSearch.EngineScope || context.engineScope == SceneSearch.EngineScope)
        {
            // Cache Scene objects.
        }
    }

    public virtual void EndSession(ISearchContext context)
    {
        // Flush any cached data.
    }

    public virtual void BeginSearch(ISearchContext context, string query)
    {
    }

    public virtual void EndSearch(ISearchContext context)
    {
    }

    public string name => "My Engine Service";
}

[SceneSearchEngine]
class SampleSceneFilterEngine : BaseEngine, ISceneSearchEngine
{
    public bool Filter(ISearchContext context, string query, HierarchyProperty objectToFilter)
    {
        // Use cached Scene objects.
        // ...
        return true;
    }
}

[ProjectSearchEngine]
class SampleProjectSearchEngine : BaseEngine, IProjectSearchEngine
{
    public IEnumerable<string> Search(ISearchContext context, string query, Action<IEnumerable<string>> asyncItemsReceived)
    {
        // Use cached Assets.
        // ...
        return new List<string>();
    }
}

[ObjectSelectorEngine]
class SampleObjectSelectorEngine : BaseEngine, IObjectSelectorEngine
{
    public bool SelectObject(ISearchContext context, Action<UnityEngine.Object, bool> onObjectSelectorClosed, Action<UnityEngine.Object> onObjectSelectedUpdated)
    {
        // Use cached Assets and Scene objects.
        return true;
    }

    public void SetSearchFilter(ISearchContext context, string searchFilter)
    {}
}

변수

SceneIdentifies a search for Scene engines.
ProjectIdentifies a search for Project engines.
ObjectSelectorIdentifies a search for ObjectSelector engines.
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961