版本: Unity 6 (6000.0)
语言英语
  • C#

SearchEngineScope

枚举

建议更改

成功!

感谢您帮助我们提高 Unity 文档的质量。虽然我们无法接受所有提交,但我们会阅读用户提出的每一个建议更改,并在适用的情况下进行更新。

关闭

提交失败

由于某些原因,您的建议更改无法提交。请<a>稍后再试</a>。感谢您抽出时间帮助我们提高 Unity 文档的质量。

关闭

取消

描述

包含可用搜索引擎范围的枚举。

搜索引擎范围标识搜索来自哪里。这在为基础引擎功能实现单个入口点时非常有用。

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)
    {}
}

属性

场景标识对场景引擎的搜索。
项目标识对项目引擎的搜索。
对象选择器标识对对象选择器引擎的搜索。