internal static SearchFilter CreateFilter(string searchString, SearchableEditorWindow.SearchMode searchMode) { SearchFilter filter = new SearchFilter(); if (string.IsNullOrEmpty(searchString)) return filter; switch (searchMode) { case SearchableEditorWindow.SearchMode.All: if (!SearchUtility.ParseSearchString(searchString, filter)) { filter.nameFilter = searchString; filter.classNames = new string[1]{ searchString }; filter.assetLabels = new string[1]{ searchString }; filter.assetBundleNames = new string[1]{ searchString }; filter.showAllHits = true; break; } break; case SearchableEditorWindow.SearchMode.Name: filter.nameFilter = searchString; break; case SearchableEditorWindow.SearchMode.Type: filter.classNames = new string[1]{ searchString }; break; case SearchableEditorWindow.SearchMode.Label: filter.assetLabels = new string[1]{ searchString }; break; case SearchableEditorWindow.SearchMode.AssetBundleName: filter.assetBundleNames = new string[1]{ searchString }; break; } return filter; }
private static void OnSearchForReferences() { int activeInstanceId = Selection.activeInstanceID; string str = AssetDatabase.GetAssetPath(activeInstanceId).Substring(7); if (str.IndexOf(' ') != -1) { str = 34.ToString() + str + (object)'"'; } string searchFilter; if (AssetDatabase.IsMainAsset(activeInstanceId)) { searchFilter = "ref:" + str; } else { searchFilter = "ref:" + (object)activeInstanceId + ":" + str; } using (List <SearchableEditorWindow> .Enumerator enumerator = SearchableEditorWindow.searchableWindows.GetEnumerator()) { while (enumerator.MoveNext()) { SearchableEditorWindow current = enumerator.Current; if (current.m_HierarchyType == HierarchyType.GameObjects) { current.SetSearchFilter(searchFilter, SearchableEditorWindow.SearchMode.All, false); current.m_HasSearchFilterFocus = true; current.Repaint(); } } } }
internal void SelectNextSearchResult() { using (List <SearchableEditorWindow> .Enumerator enumerator = SearchableEditorWindow.searchableWindows.GetEnumerator()) { while (enumerator.MoveNext()) { SearchableEditorWindow current = enumerator.Current; if (current is SceneHierarchyWindow) { ((SceneHierarchyWindow)current).SelectNext(); break; } } } }
internal virtual void SetSearchFilter(string searchFilter, SearchableEditorWindow.SearchMode mode, bool setAll) { this.m_SearchMode = mode; this.m_SearchFilter = searchFilter; if (setAll) { using (List <SearchableEditorWindow> .Enumerator enumerator = SearchableEditorWindow.searchableWindows.GetEnumerator()) { while (enumerator.MoveNext()) { SearchableEditorWindow current = enumerator.Current; if ((UnityEngine.Object)current != (UnityEngine.Object) this && current.m_HierarchyType == this.m_HierarchyType && current.m_HierarchyType != HierarchyType.Assets) { current.SetSearchFilter(this.m_SearchFilter, this.m_SearchMode, false); } } } } this.Repaint(); EditorApplication.Internal_CallSearchHasChanged(); }
public static SerializedPropertyTreeView.Column[] CreateEmissivesColumns(out string[] propNames) { var columns = new[] { new SerializedPropertyTreeView.Column // 0: Icon { headerContent = Styles.SelectObjects, headerTextAlignment = TextAlignment.Left, sortedAscending = true, sortingArrowAlignment = TextAlignment.Center, width = 20, minWidth = 20, maxWidth = 20, autoResize = false, allowToggleVisibility = true, propertyName = "m_LightmapFlags", dependencyIndices = null, compareDelegate = null, drawDelegate = (Rect r, SerializedProperty prop, SerializedProperty[] dep) => { if (GUI.Button(r, Styles.SelectObjectsButton, "label")) { SearchableEditorWindow.SearchForReferencesToInstanceID(prop.serializedObject.targetObject.GetInstanceID()); } } }, new SerializedPropertyTreeView.Column // 1: Name { headerContent = Styles.Name, headerTextAlignment = TextAlignment.Left, sortedAscending = true, sortingArrowAlignment = TextAlignment.Center, width = 200, minWidth = 100, autoResize = false, allowToggleVisibility = true, propertyName = null, dependencyIndices = null, compareDelegate = SerializedPropertyTreeView.DefaultDelegates.s_CompareName, drawDelegate = SerializedPropertyTreeView.DefaultDelegates.s_DrawName, filter = new SerializedPropertyFilters.Name() }, new SerializedPropertyTreeView.Column // 2: GI { headerContent = Styles.GlobalIllumination, headerTextAlignment = TextAlignment.Left, sortedAscending = true, sortingArrowAlignment = TextAlignment.Center, width = 120, minWidth = 70, autoResize = false, allowToggleVisibility = true, propertyName = "m_LightmapFlags", dependencyIndices = null, compareDelegate = SerializedPropertyTreeView.DefaultDelegates.s_CompareInt, drawDelegate = (Rect r, SerializedProperty prop, SerializedProperty[] dep) => { if (!prop.serializedObject.targetObject.GetType().Equals(typeof(Material))) { return; } using (new EditorGUI.DisabledScope(!IsEditable(prop.serializedObject.targetObject))) { MaterialGlobalIlluminationFlags giFlags = ((prop.intValue & (int)MaterialGlobalIlluminationFlags.BakedEmissive) != 0) ? MaterialGlobalIlluminationFlags.BakedEmissive : MaterialGlobalIlluminationFlags.RealtimeEmissive; int[] lightmapEmissiveValues = { (int)MaterialGlobalIlluminationFlags.RealtimeEmissive, (int)MaterialGlobalIlluminationFlags.BakedEmissive }; EditorGUI.BeginChangeCheck(); giFlags = (MaterialGlobalIlluminationFlags)EditorGUI.IntPopup(r, (int)giFlags, Styles.LightmapEmissiveStrings, lightmapEmissiveValues); if (EditorGUI.EndChangeCheck()) { Material material = (Material)prop.serializedObject.targetObject; Undo.RecordObjects(new Material[] { material }, "Modify GI Settings of " + material.name); material.globalIlluminationFlags = giFlags; prop.serializedObject.Update(); } } } }, new SerializedPropertyTreeView.Column // 3: Color { headerContent = Styles.Color, headerTextAlignment = TextAlignment.Left, sortedAscending = true, sortingArrowAlignment = TextAlignment.Center, width = 70, minWidth = 40, autoResize = false, allowToggleVisibility = true, propertyName = "m_Shader", dependencyIndices = null, compareDelegate = (SerializedProperty lhs, SerializedProperty rhs) => { float lh, ls, lv, rh, rs, rv; Color.RGBToHSV(((Material)lhs.serializedObject.targetObject).GetColor("_EmissionColor"), out lh, out ls, out lv); Color.RGBToHSV(((Material)rhs.serializedObject.targetObject).GetColor("_EmissionColor"), out rh, out rs, out rv); return(lv.CompareTo(rv)); }, drawDelegate = (Rect r, SerializedProperty prop, SerializedProperty[] dep) => { if (!prop.serializedObject.targetObject.GetType().Equals(typeof(Material))) { return; } using (new EditorGUI.DisabledScope(!IsEditable(prop.serializedObject.targetObject))) { Material material = (Material)prop.serializedObject.targetObject; Color color = material.GetColor("_EmissionColor"); EditorGUI.BeginChangeCheck(); Color newValue = EditorGUI.ColorField(r, GUIContent.Temp(""), color, true, false, true); if (EditorGUI.EndChangeCheck()) { Undo.RecordObjects(new Material[] { material }, "Modify Emission Color of " + material.name); material.SetColor("_EmissionColor", newValue); } } }, copyDelegate = (SerializedProperty target, SerializedProperty source) => { Material sourceMaterial = (Material)source.serializedObject.targetObject; Color color = sourceMaterial.GetColor("_EmissionColor"); Material targetMaterial = (Material)target.serializedObject.targetObject; targetMaterial.SetColor("_EmissionColor", color); } } }; return(FinalizeColumns(columns, out propNames)); }
public static SerializedPropertyTreeView.Column[] CreateEmissivesColumns(out string[] propNames) { SerializedPropertyTreeView.Column[] expr_07 = new SerializedPropertyTreeView.Column[4]; int arg_9B_1 = 0; SerializedPropertyTreeView.Column column = new SerializedPropertyTreeView.Column(); column.headerContent = LightTableColumns.Styles.SelectObjects; column.headerTextAlignment = TextAlignment.Left; column.sortedAscending = true; column.sortingArrowAlignment = TextAlignment.Center; column.width = 20f; column.minWidth = 20f; column.maxWidth = 20f; column.autoResize = false; column.allowToggleVisibility = true; column.propertyName = "m_LightmapFlags"; column.dependencyIndices = null; column.compareDelegate = null; column.drawDelegate = delegate(Rect r, SerializedProperty prop, SerializedProperty[] dep) { if (GUI.Button(r, LightTableColumns.Styles.SelectObjectsButton, "label")) { SearchableEditorWindow.SearchForReferencesToInstanceID(prop.serializedObject.targetObject.GetInstanceID()); } }; expr_07[arg_9B_1] = column; expr_07[1] = new SerializedPropertyTreeView.Column { headerContent = LightTableColumns.Styles.Name, headerTextAlignment = TextAlignment.Left, sortedAscending = true, sortingArrowAlignment = TextAlignment.Center, width = 200f, minWidth = 100f, autoResize = false, allowToggleVisibility = true, propertyName = null, dependencyIndices = null, compareDelegate = SerializedPropertyTreeView.DefaultDelegates.s_CompareName, drawDelegate = SerializedPropertyTreeView.DefaultDelegates.s_DrawName, filter = new SerializedPropertyFilters.Name() }; int arg_1A6_1 = 2; column = new SerializedPropertyTreeView.Column(); column.headerContent = LightTableColumns.Styles.GlobalIllumination; column.headerTextAlignment = TextAlignment.Left; column.sortedAscending = true; column.sortingArrowAlignment = TextAlignment.Center; column.width = 120f; column.minWidth = 70f; column.autoResize = false; column.allowToggleVisibility = true; column.propertyName = "m_LightmapFlags"; column.dependencyIndices = null; column.compareDelegate = SerializedPropertyTreeView.DefaultDelegates.s_CompareInt; column.drawDelegate = delegate(Rect r, SerializedProperty prop, SerializedProperty[] dep) { if (prop.serializedObject.targetObject.GetType().Equals(typeof(Material))) { using (new EditorGUI.DisabledScope(!LightTableColumns.IsEditable(prop.serializedObject.targetObject))) { MaterialGlobalIlluminationFlags materialGlobalIlluminationFlags = ((prop.intValue & 2) == 0) ? MaterialGlobalIlluminationFlags.RealtimeEmissive : MaterialGlobalIlluminationFlags.BakedEmissive; int[] optionValues = new int[] { 1, 2 }; EditorGUI.BeginChangeCheck(); materialGlobalIlluminationFlags = (MaterialGlobalIlluminationFlags)EditorGUI.IntPopup(r, (int)materialGlobalIlluminationFlags, LightTableColumns.Styles.LightmapEmissiveStrings, optionValues); if (EditorGUI.EndChangeCheck()) { Material material = (Material)prop.serializedObject.targetObject; Undo.RecordObjects(new Material[] { material }, "Modify GI Settings of " + material.name); material.globalIlluminationFlags = materialGlobalIlluminationFlags; prop.serializedObject.Update(); } } } }; expr_07[arg_1A6_1] = column; int arg_26F_1 = 3; column = new SerializedPropertyTreeView.Column(); column.headerContent = LightTableColumns.Styles.Intensity; column.headerTextAlignment = TextAlignment.Left; column.sortedAscending = true; column.sortingArrowAlignment = TextAlignment.Center; column.width = 70f; column.minWidth = 40f; column.autoResize = false; column.allowToggleVisibility = true; column.propertyName = "m_Shader"; column.dependencyIndices = null; column.compareDelegate = delegate(SerializedProperty lhs, SerializedProperty rhs) { float num; float num2; float num3; Color.RGBToHSV(((Material)lhs.serializedObject.targetObject).GetColor("_EmissionColor"), out num, out num2, out num3); float num4; float num5; float value; Color.RGBToHSV(((Material)rhs.serializedObject.targetObject).GetColor("_EmissionColor"), out num4, out num5, out value); return(num3.CompareTo(value)); }; column.drawDelegate = delegate(Rect r, SerializedProperty prop, SerializedProperty[] dep) { if (prop.serializedObject.targetObject.GetType().Equals(typeof(Material))) { using (new EditorGUI.DisabledScope(!LightTableColumns.IsEditable(prop.serializedObject.targetObject))) { Material material = (Material)prop.serializedObject.targetObject; Color color = material.GetColor("_EmissionColor"); ColorPickerHDRConfig colorPickerHDRConfig = LightTableColumns.s_ColorPickerHDRConfig ?? ColorPicker.defaultHDRConfig; EditorGUI.BeginChangeCheck(); Color value = EditorGUI.ColorBrightnessField(r, GUIContent.Temp(""), color, colorPickerHDRConfig.minBrightness, colorPickerHDRConfig.maxBrightness); if (EditorGUI.EndChangeCheck()) { Undo.RecordObjects(new Material[] { material }, "Modify Color of " + material.name); material.SetColor("_EmissionColor", value); } } } }; column.copyDelegate = delegate(SerializedProperty target, SerializedProperty source) { Material material = (Material)source.serializedObject.targetObject; Color color = material.GetColor("_EmissionColor"); Material material2 = (Material)target.serializedObject.targetObject; material2.SetColor("_EmissionColor", color); }; expr_07[arg_26F_1] = column; SerializedPropertyTreeView.Column[] columns = expr_07; return(LightTableColumns.FinalizeColumns(columns, out propNames)); }
protected virtual LightingExplorerTableColumn[] GetEmissivesColumns() { return(new[] { new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Custom, Styles.SelectObjects, "m_LightmapFlags", 20, (r, prop, dep) => { if (GUI.Button(r, Styles.SelectObjectsButton, "label")) { SearchableEditorWindow.SearchForReferencesToInstanceID(prop.serializedObject.targetObject.GetInstanceID()); } }), // 0: Icon new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Name, Styles.Name, null, 200), // 1: Name new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Int, Styles.GlobalIllumination, "m_LightmapFlags", 120, (r, prop, dep) => { if (!prop.serializedObject.targetObject.GetType().Equals(typeof(Material))) { return; } using (new EditorGUI.DisabledScope(!IsEditable(prop.serializedObject.targetObject))) { MaterialGlobalIlluminationFlags giFlags = ((prop.intValue & (int)MaterialGlobalIlluminationFlags.BakedEmissive) != 0) ? MaterialGlobalIlluminationFlags.BakedEmissive : MaterialGlobalIlluminationFlags.RealtimeEmissive; int[] lightmapEmissiveValues = { (int)MaterialGlobalIlluminationFlags.RealtimeEmissive, (int)MaterialGlobalIlluminationFlags.BakedEmissive }; EditorGUI.BeginProperty(r, GUIContent.none, prop); EditorGUI.BeginChangeCheck(); giFlags = (MaterialGlobalIlluminationFlags)EditorGUI.IntPopup(r, (int)giFlags, Styles.LightmapEmissiveStrings, lightmapEmissiveValues); if (EditorGUI.EndChangeCheck()) { Material material = (Material)prop.serializedObject.targetObject; material.globalIlluminationFlags = giFlags; prop.serializedObject.Update(); } EditorGUI.EndProperty(); } }), // 2: GI new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Custom, Styles.Color, "m_Shader", 120, (r, prop, dep) => { if (!prop.serializedObject.targetObject.GetType().Equals(typeof(Material))) { return; } using (new EditorGUI.DisabledScope(!IsEditable(prop.serializedObject.targetObject))) { Material material = (Material)prop.serializedObject.targetObject; Color color = material.GetColor("_EmissionColor"); EditorGUI.BeginProperty(r, GUIContent.none, prop); EditorGUI.BeginChangeCheck(); Color newValue = EditorGUI.ColorField(r, GUIContent.Temp(""), color, true, false, true); if (EditorGUI.EndChangeCheck()) { material.SetColor("_EmissionColor", newValue); } EditorGUI.EndProperty(); } }, (lhs, rhs) => { float lh, ls, lv, rh, rs, rv; Color.RGBToHSV(((Material)lhs.serializedObject.targetObject).GetColor("_EmissionColor"), out lh, out ls, out lv); Color.RGBToHSV(((Material)rhs.serializedObject.targetObject).GetColor("_EmissionColor"), out rh, out rs, out rv); return lv.CompareTo(rv); }, (target, source) => { Material sourceMaterial = (Material)source.serializedObject.targetObject; Color color = sourceMaterial.GetColor("_EmissionColor"); Material targetMaterial = (Material)target.serializedObject.targetObject; targetMaterial.SetColor("_EmissionColor", color); }) // 3: Color }); }
// Pre 4.0 interface (kept for backwards compability) public void SetSearchFilter(string searchString, int mode) { SearchFilter filter = SearchableEditorWindow.CreateFilter(searchString, (SearchableEditorWindow.SearchMode)mode); SetSearchFilter(filter); }
private static void OnSearchForReferences() { SearchableEditorWindow.SearchForReferencesToInstanceID(Selection.activeInstanceID); }
// Returns number of rows in search result int InitializeSearchResults(HierarchyProperty property, int minAllowedDepth) { // Search setup const bool kShowItemHasChildren = false; const int kItemDepth = 0; int currentSceneHandle = -1; int row = 0; var searchFilter = SearchableEditorWindow.CreateFilter(searchString, (SearchableEditorWindow.SearchMode)m_SearchMode); var searchContext = (SearchService.HierarchySearchContext)m_SearchSessionHandler.context; searchContext.filter = searchFilter; searchContext.rootProperty = property; m_SearchSessionHandler.BeginSearch(searchString); var headerRows = new List <int>(); while (property.NextWithDepthCheck(null, minAllowedDepth)) { if (!SearchService.Scene.Filter(m_SearchString, property, searchContext)) { property.SetFilteredVisibility(false); continue; } property.SetFilteredVisibility(true); var item = EnsureCreatedItem(row); // Add scene headers when encountering a new scene (and it's not a header in itself) if (AddSceneHeaderToSearchIfNeeded(item, property, ref currentSceneHandle)) { row++; headerRows.Add(row); if (IsSceneHeader(property)) { continue; // no need to add it } item = EnsureCreatedItem(row); // prepare for item below } InitTreeViewItem(item, property, kShowItemHasChildren, kItemDepth); row++; } m_SearchSessionHandler.EndSearch(); int numRows = row; // Now sort scene section if (headerRows.Count > 0) { int currentSortStart = headerRows[0]; for (int i = 1; i < headerRows.Count; i++) { int count = headerRows[i] - currentSortStart - 1; m_ListOfRows.Sort(currentSortStart, count, new TreeViewItemAlphaNumericSort()); currentSortStart = headerRows[i]; } // last section m_ListOfRows.Sort(currentSortStart, numRows - currentSortStart, new TreeViewItemAlphaNumericSort()); } return(numRows); }
internal override void SetSearchFilter(string searchFilter, SearchableEditorWindow.SearchMode searchMode, bool setAll) { base.SetSearchFilter(searchFilter, searchMode, setAll); if (this.m_DidSelectSearchResult && string.IsNullOrEmpty(searchFilter)) { this.m_DidSelectSearchResult = false; this.FrameObjectPrivate(Selection.activeInstanceID, true, false); if (GUIUtility.keyboardControl == 0) { GUIUtility.keyboardControl = this.m_TreeViewKeyboardControlID; } } }
public void SetSearchFilter(string searchString, int mode) { this.SetSearchFilter(SearchableEditorWindow.CreateFilter(searchString, (SearchableEditorWindow.SearchMode)mode)); }
internal override void SetSearchFilter(string searchFilter, SearchableEditorWindow.SearchMode mode, bool setAll) { if ((base.m_SearchFilter == string.Empty) || (searchFilter == string.Empty)) { this.m_StartSearchFilterTime = EditorApplication.timeSinceStartup; } base.SetSearchFilter(searchFilter, mode, setAll); }
internal virtual void SetSearchFilter(string searchFilter, SearchableEditorWindow.SearchMode mode, bool setAll) { this.m_SearchMode = mode; this.m_SearchFilter = searchFilter; if (setAll) { foreach (SearchableEditorWindow current in SearchableEditorWindow.searchableWindows) { if (current != this && current.m_HierarchyType == this.m_HierarchyType && current.m_HierarchyType != HierarchyType.Assets) { current.SetSearchFilter(this.m_SearchFilter, this.m_SearchMode, false); } } } base.Repaint(); EditorApplication.Internal_CallSearchHasChanged(); }
internal virtual void SetSearchFilter(string searchFilter, SearchableEditorWindow.SearchMode mode, bool setAll) { this.m_SearchMode = mode; this.m_SearchFilter = searchFilter; if (setAll) { using (List<SearchableEditorWindow>.Enumerator enumerator = SearchableEditorWindow.searchableWindows.GetEnumerator()) { while (enumerator.MoveNext()) { SearchableEditorWindow current = enumerator.Current; if ((UnityEngine.Object) current != (UnityEngine.Object) this && current.m_HierarchyType == this.m_HierarchyType && current.m_HierarchyType != HierarchyType.Assets) current.SetSearchFilter(this.m_SearchFilter, this.m_SearchMode, false); } } } this.Repaint(); EditorApplication.Internal_CallSearchHasChanged(); }