public void AddResultsFromSubsearch(SearchItem parentItem, SearchResultGroup resultsGroup) { foreach (SearchResult result in resultsGroup.results) { MatchFound(result, parentItem); } }
public void OnSearchComplete() { bool foundNull = true; while (foundNull) { foundNull = results.Remove(null); } int pages = Mathf.CeilToInt((float)resultsCount / (float)resultsPerPage); pageNames = new String[pages]; for (int i = 0; i < pages; i++) { pageNames[i] = (i + 1).ToString(); } int items = 1; for (int i = 0; i < results.Count; i++) { SearchResultGroup result = results[i]; result.startIndex = items - 1; // items += result.results.Count; // Debug.Log("[SearchResultSet] result:"+i+" startIndex:"+result.startIndex+" endIndex:"+result.endIndex); for (int j = 0; j < result.results.Count; j++) { SearchResult sr = result.results[j]; sr.recordNum = items++; } result.endIndex = items - 1; } }
public void Add(SearchResult result, SearchItem item) { SearchResultGroup resultGroup = results[item.sortIndex]; resultGroup.AddResult(result); result.resultSet = this; resultsCount++; }
public void Add(SearchResult result, SearchItem item) { SearchResultGroup resultGroup = results[item.sortIndex]; // for(int i = 0; i < 10;i++) // { resultGroup.AddResult(result); resultsCount++; // } }
static void replaceInstances(SearchJob parentJob, SearchItem item, GameObject oldValue, GameObject newValue) { SearchItemSet searchSet = new SearchItemSet(); searchSet.OnDeserialization(); searchSet.AddNew(Keys.Global, false); SearchItemGlobal searchItem = (SearchItemGlobal)searchSet.items[0]; searchItem.SetType("Object"); DynamicTypeObject dto = (DynamicTypeObject)searchItem.GetDTDFor(typeof(UnityEngine.Object)); dto.SearchSubObjects = true; dto.SetObject(oldValue); ReplaceItemObject replaceItem = (ReplaceItemObject)dto.ReplaceItem; replaceItem.SetObject(newValue); SearchOptions options = new SearchOptions(); options.searchType = SearchType.SearchAndReplace; // does this matter anymore since asset scope is now essentially defined by what assets are passed in? SearchScopeData searchScope = new SearchScopeData(ProjectScope.SpecificLocation, AssetScope.Prefabs, new ObjectID(AssetDatabase.LoadAssetAtPath <UnityEngine.Object>(parentJob.assetData.assetPath)), false, parentJob.scope.loadPrefab); SearchJob subJob = new SearchJob(searchSet, options, searchScope); SearchAssetData assetData = parentJob.assetData.Clone(); subJob.AddAsset(assetData); subJob.Execute(); // Now that we've executed the job we have to save a list of all objects from search results, because as soon as // we swap out the new object, the old object's position may shift in the hierarchy, making the PathInfo stale. SearchResultGroup group = subJob.resultSet.results[searchItem.sortIndex]; List <UnityEngine.Object> resultObjects = new List <Object>(); foreach (SearchResult result in group.results) { UnityEngine.Object resultObj = EditorUtility.InstanceIDToObject(result.pathInfo.objectID); resultObjects.Add(resultObj); } UnityEngine.Object.DestroyImmediate(oldValue); // now that we've deleted the object, let's rebuild the objects. for (int i = 0; i < resultObjects.Count; i++) { SearchResult result = group.results[i]; result.pathInfo = PathInfo.GetPathInfo(resultObjects[i], assetData); } parentJob.AddResultsFromSubsearch(item, subJob.resultSet.results[searchItem.sortIndex]); }
int getStartGroup(int start) { for (int i = 0; i < results.Count; i++) { SearchResultGroup result = results[i]; if (result.startIndex <= start && result.endIndex >= start) { // Debug.Log("[SearchResultSet] getStartGroup:"+i+ " start:"+start); return(i); } } return(results.Count - 1); }
void drawPage() { if (resultsCount == 0) { return; } else { // Debug.Log("[SearchResultSet] start:"+start+" end:"+end); int itemsDrawn = 0; int itemsToDraw = end - start; int itemsIndex = start; int currentResultIndex = getStartGroup(start); // Debug.Log("[SearchResultSet] drawing from result: "+currentResultIndex+ " itemsToDraw:"+itemsToDraw+" itemsIndex:"+itemsIndex + " resultsCount:"+resultsCount); while (itemsDrawn < itemsToDraw) { SearchResultGroup currentResult = results[currentResultIndex]; // Debug.Log("[SearchResultSet] itemsIndex:"+itemsIndex + " currentResult.startIndex"+ currentResult.startIndex); int groupIndex = itemsIndex - currentResult.startIndex; int itemsToDrawInGroup = Math.Min(itemsToDraw - itemsDrawn, currentResult.results.Count - groupIndex); currentResult.Draw(groupIndex, itemsToDrawInGroup); itemsDrawn += itemsToDrawInGroup; itemsIndex += itemsToDrawInGroup; currentResultIndex++; } //Draw any empty results until the next record is found. bool foundResults = false; int tries = 0; do { if (currentResultIndex < results.Count) { SearchResultGroup currentResult = results[currentResultIndex]; if (currentResult.results.Count == 0) { currentResult.Draw(0, 0); //keep going. currentResultIndex++; } else { //we found a non-empty result, exit. foundResults = true; } } tries++; }while(!foundResults && tries < 10); } }
public void Select(SearchResult result, bool shiftSelect, bool ctrlSelect) { bool selectInProject = shiftSelect || ctrlSelect; if (ctrlSelect) { //modify the selection. if (selection.Contains(result)) { selection.Remove(result); result.Selected = false; } else { selection.Add(result); } } else if (shiftSelect) { Deselect(); if (selection.Count > 0) { SearchResult firstResult = selection[0]; SearchResult lastResult = result; if (firstResult.recordNum > lastResult.recordNum) { // change places! var tmp = lastResult; lastResult = firstResult; firstResult = tmp; } selection.Clear(); if (firstResult == lastResult) { selection.Add(firstResult); } else { int index = firstResult.resultGroup.results.IndexOf(firstResult); bool completed = false; int infiniteLoopCheck = 0; SearchResultGroup currentGroup = firstResult.resultGroup; while (!completed) { SearchResult nextResult = currentGroup.results[index]; selection.Add(nextResult); if (nextResult == lastResult) { completed = true; } else { index++; if (currentGroup.results.Count == index) { currentGroup = results[results.IndexOf(currentGroup) + 1]; index = 0; } } infiniteLoopCheck++; if (infiniteLoopCheck == 100) { completed = true; } } } } else { // There is no selection! This is now the selection. selection.Add(result); } } else { // standard selection Deselect(); selection.Clear(); selection.Add(result); } applySelection(selectInProject); }