SearchValue OnPropertyFilter(GameObject go, string propertyName) { if (!go) { return(SearchValue.invalid); } if (string.IsNullOrEmpty(propertyName)) { return(SearchValue.invalid); } using (var view = SearchMonitor.GetView()) { var documentKey = SearchUtils.GetDocumentKey(go); var recordKey = PropertyDatabase.CreateRecordKey(documentKey, PropertyDatabase.CreatePropertyHash(propertyName)); if (view.TryLoadProperty(recordKey, out object data) && data is SearchValue sv) { return(sv); } foreach (var c in EnumerateSubObjects(go)) { var property = FindPropertyValue(c, propertyName); if (property.valid) { view.StoreProperty(recordKey, property); return(property); } } view.StoreProperty(recordKey, SearchValue.invalid); } return(SearchValue.invalid); }
SearchValue OnPropertyFilter(GameObject go, string propertyName) { if (!go) { return(SearchValue.invalid); } if (string.IsNullOrEmpty(propertyName)) { return(SearchValue.invalid); } #if USE_PROPERTY_DATABASE using (var view = SearchMonitor.GetView()) #endif { #if USE_PROPERTY_DATABASE var documentKey = SearchUtils.GetDocumentKey(go); var recordKey = PropertyDatabase.CreateRecordKey(documentKey, PropertyDatabase.CreatePropertyHash(propertyName)); if (view.TryLoadProperty(recordKey, out object data)) { return((SearchValue)data); } #endif var gocs = go.GetComponents <Component>(); for (int componentIndex = 0; componentIndex < gocs.Length; ++componentIndex) { var c = gocs[componentIndex]; if (!c || (c.hideFlags & HideFlags.HideInInspector) == HideFlags.HideInInspector) { continue; } var property = FindPropertyValue(c, propertyName); if (property.valid) { #if USE_PROPERTY_DATABASE view.StoreProperty(recordKey, property); #endif return(property); } } #if USE_PROPERTY_DATABASE view.StoreProperty(recordKey, SearchValue.invalid); #endif } return(SearchValue.invalid); }
private IEnumerator SearchItems(SearchContext context, SearchProvider provider) { if (!string.IsNullOrEmpty(context.searchQuery)) { if (m_HierarchyChanged) { m_SceneQueryEngine = new SceneQueryEngine(SearchUtils.FetchGameObjects()); m_HierarchyChanged = false; } IEnumerable <GameObject> subset = null; if (context.subset != null) { subset = context.subset .Where(item => item.provider.id == "scene") .Select(item => ObjectFromItem(item)) .Where(obj => obj != null); } #if USE_PROPERTY_DATABASE using (SearchMonitor.GetView()) #endif { yield return(m_SceneQueryEngine.Search(context, provider, subset) .Where(go => go) .Select(go => AddResult(context, provider, go))); } } else if (context.filterType != null && string.IsNullOrEmpty(context.searchQuery)) { yield return(UnityEngine.Object.FindObjectsOfType(context.filterType) .Select(obj => { if (obj is Component c) { return c.gameObject; } return obj as GameObject; }) .Where(go => go) .Select(go => AddResult(context, provider, go))); } }