Version: 2022.2

QueryListBlockAttribute

class in UnityEditor.Search

切换到手册

描述

This attribute can be used on a class deriving from QueryListBlock to display in query builder mode a special block that will propose a fixed set of values when clicked.

The following example shows how to display a custom list block for the shader filter block.

[QueryListBlock("Decal", "Shader", "shader")]
class ShaderDecalBlockList : QueryListBlock
{
    public ShaderDecalBlockList(IQuerySource source, string id, string value, QueryListBlockAttribute attr)
        : base(source, id, value, attr)
    {
    }

    public override IEnumerable<SearchProposition> GetPropositions(SearchPropositionFlags flags = SearchPropositionFlags.None)
    {
        yield return new SearchProposition(category: null, "HDRP Decal", "Decal", icon: GetShaderIcon() as Texture2D);
        yield return new SearchProposition(category: null, "URP Decal", "DecalURP", icon: GetShaderIcon() as Texture2D);
    }
}

变量

categoryCategory.
idFilter id of the block.
idsA set of IDs for which the list block will be displayed.
nameDisplayed name of the block.
opDefault operator assigned to the filter when the value changes.
typeThe list block type is used to get the the icon to be displayed instead of the block name.

构造函数

QueryListBlockAttributeRegister a list block for a given filter.