指定评估器不支持工作线程评估,且应仅在主线程中评估评估器。如果评估器使用线程不安全的 Unity API(比如 AssetDatabase),则可能是这种情况。
[Description("Returns asset paths corresponding to a list of instance ids")] [SearchExpressionEvaluator("IdsToPaths", SearchExpressionEvaluationHints.ThreadNotSupported, SearchExpressionType.Iterable)] public static IEnumerable<SearchItem> IdsToPath(SearchExpressionContext c) { foreach (var idItem in c.args[0].Execute(c)) { if (SearchExpression.TryConvertToDouble(idItem, out var idNum)) { var id = (int)idNum; var path = AssetDatabase.GetAssetPath(id); if (!string.IsNullOrEmpty(path)) { yield return SearchExpression.CreateItem(path, c.ResolveAlias("asset path")); } } } }