Version: 2022.3
언어: 한국어

SceneQueryEngineParameterTransformerAttribute

class in UnityEditor.Search.Providers

/

다음으로부터 상속:Search.QueryEngineParameterTransformerAttribute

매뉴얼로 전환

설명

Attribute class that defines a custom parameter transformer function applied for a query running in a scene provider defined by a scene custom filter using SceneQueryEngineFilterAttribute.

[SceneQueryEngineParameterTransformer]
static Vector3 DistanceParamHandler(string param)
{
    if (param == "selection")
    {
        var centerPoint = Selection.gameObjects.Select(go => go.transform.position).Aggregate((v1, v2) => v1 + v2);
        centerPoint /= Selection.gameObjects.Length;
        return centerPoint;
    }

    if (param.StartsWith("[") && param.EndsWith("]"))
    {
        param = param.Trim('[', ']');
        var vectorTokens = param.Split(',');
        var vectorValues = vectorTokens.Select(token => float.Parse(token, CultureInfo.InvariantCulture.NumberFormat)).ToList();
        while (vectorValues.Count < 3)
            vectorValues.Add(0f);
        return new Vector3(vectorValues[0], vectorValues[1], vectorValues[2]);
    }

    var obj = GameObject.Find(param);
    if (!obj)
        return Vector3.zero;
    return obj.transform.position;
}

Used with

[SceneQueryEngineFilter("dist", "DistanceParamHandler", new[] {"=", "!=", "<", ">", "<=", ">="})]
static float DistanceHandler(GameObject go, Vector3 p)
{
    return (go.transform.position - p).magnitude;
}

상속된 멤버

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