public static SavedSearches PopulateFromDisk() { SavedSearches ss = null; initSearchPath(); try{ ss = (SavedSearches)SerializationUtil.Deserialize(path); if (ss != null) { ss.OnDeserialization(); } }catch (System.Exception ex) { Debug.LogError("An error occurred deserializing saved searches. If this issue persists please report the problem to [email protected]. Error: " + ex); } if (ss == null) { ss = new SavedSearches(); ss.OnDeserialization(); return(ss); } else { return(ss); } }
void init() { if (searchOptions == null) { _initialized = false; } if (!_initialized) { _initialized = true; Instance = this; searchType = new PopupData(0, new string[] { Keys.search, Keys.searchAndReplace }, Keys.prefSearchType, ""); searchType.boxPad = 10; int replacePref = EditorPrefs.GetInt(Keys.prefSearchType, 0); replaceMode = replacePref == 0 ? false : true; searchForIndex = EditorPrefs.GetInt(Keys.prefSearchFor, 0); //This throws errors if done in Ctor! yay. searches = new List <SearchItemSet>(); searchesToPersist = new HashSet <SearchItemSet>(); foreach (string searchKey in searchForOptions) { SearchItemSet s = SearchItemSet.PopulateFromDisk(searchKey); searches.Add(s); } SearchItemSet savedSearch = SearchItemSet.PopulateFromDisk(Keys.SavedSearch); searches.Add(savedSearch); searchOptions = SearchOptions.PopulateFromDisk(); searchOptions.searchType = replaceMode ? SearchType.SearchAndReplace : SearchType.Search; savedSearches = SavedSearches.PopulateFromDisk(); // now that we've loaded all potential searches, which one has the user // selected? if (searchForIndex < 3) { currentSearch = searches[searchForIndex]; } else { // If the index is above, then we have a saved search selected. The fourth // sis is the currently loaded saved search. currentSearch = searches[3]; } //EditorStyles does not exist in Constructor?? richTextStyle = new GUIStyle(EditorStyles.label); richTextStyle.richText = true; richTextStyle.wordWrap = true; searchBox = new GUIStyle(EditorStyles.helpBox); searchBox.padding = new RectOffset(10, 10, 10, 10); searchBoxDragHighlight = new GUIStyle(EditorStyles.helpBox); searchBoxDragHighlight.normal.background = EditorGUIUtility.FindTexture("BoxCollider2D Icon"); searchBoxDragHighlight.border = new RectOffset(10, 10, 10, 10); searchBoxDragHighlight.padding = new RectOffset(10, 10, 10, 10); searchInnerDepthBox = new GUIStyle(EditorStyles.inspectorFullWidthMargins); searchInnerDepthBox.padding = new RectOffset(0, 0, 0, 0); resultsBox = new GUIStyle(EditorStyles.helpBox); resultsBox.padding = new RectOffset(0, 0, 10, 10); divider = new GUIStyle("box"); divider.border.top = divider.border.bottom = 1; divider.margin.top = 10; dragDivider = new GUIStyle(); dragDivider.border = new RectOffset(1, 1, 1, 1); dragDivider.margin = new RectOffset(0, 0, 0, 0); dragDivider.alignment = TextAnchor.MiddleCenter; Texture2D thumbbg = (Texture2D)findObject(EditorGUIUtility.isProSkin ? "com.eh.searchandreplace.thumbbg" : "com.eh.searchandreplace.thumbbglight"); dragDivider.normal.background = thumbbg; Texture2D thumbTex = (Texture2D)findObject("com.eh.searchandreplace.thumb"); thumb = new GUIContent(thumbTex); dragDividerNormal = dragDivider.normal.background; plusButton = new GUIStyle(GUI.skin.button); plusButton.margin.top = 2; toolbarButton = new GUIStyle(EditorStyles.toolbarButton); toolbarButton.fixedHeight = 20; toolbarButton.padding = new RectOffset(0, 0, 2, 2); resultStyle1 = new GUIStyle(); resultStyle1.margin = new RectOffset(1, 1, 0, 0); float lightgray = EditorGUIUtility.isProSkin ? 0.22f : 0.8f; resultStyle1.normal.background = MakeTex(1, 1, new Color(lightgray, lightgray, lightgray)); resultStyle2 = new GUIStyle(); float gray = EditorGUIUtility.isProSkin ? 0.26f : 0.77f; resultStyle2.normal.background = MakeTex(1, 1, new Color(gray, gray, gray)); resultStyle2.margin = new RectOffset(1, 1, 0, 0); selectedStyle = new GUIStyle(); selectedStyle.margin = new RectOffset(1, 1, 0, 0); float selectGray = EditorGUIUtility.isProSkin ? 0.22f : 0.8f; float selectBlue = EditorGUIUtility.isProSkin ? 0.4f : 0.9f; selectedStyle.normal.background = MakeTex(1, 1, new Color(selectGray, selectBlue, selectGray)); swapToggle = new GUIStyle(); swapToggle.fixedWidth = 15; swapToggle.fixedHeight = 15; swapToggle.normal.background = (Texture2D)findObject("com.eh.swap"); swapToggle.hover.background = (Texture2D)findObject("com.eh.swap.hover"); swapToggle.margin = new RectOffset(0, 4, 2, 0); errorStyle = new GUIStyle(); errorStyle.normal.background = EditorGUIUtility.FindTexture("d_console.erroricon.sml"); errorStyle.fixedWidth = 17; errorStyle.fixedHeight = 15; errorStyle.margin = new RectOffset(0, 0, 0, 0); errorStyle.padding = new RectOffset(0, 0, 0, 0); olPlusPlus = new GUIStyle((GUIStyle)"OL Plus"); olPlusPlus.margin = new RectOffset(0, 0, 2, 0); olPlusPlus.fixedWidth = 15; olPlusPlus.fixedHeight = 15; olMinusMinus = new GUIStyle((GUIStyle)"OL Minus"); olMinusMinus.margin = new RectOffset(0, 0, 2, 0); olMinusMinus.fixedWidth = 15; olMinusMinus.fixedHeight = 15; optionsToggle = new GUIStyle(); optionsToggle.normal.background = (Texture2D)findObject("com.eh.options.normal"); optionsToggle.onNormal.background = (Texture2D)findObject("com.eh.options.onNormal"); optionsToggle.fixedWidth = 15; optionsToggle.fixedHeight = 15; #if UNITY_2018_3_OR_NEWER prefabIcon = EditorGUIUtility.FindTexture("Prefab Icon"); #else prefabIcon = EditorGUIUtility.FindTexture("PrefabNormal Icon"); #endif scriptIcon = EditorGUIUtility.FindTexture("cs Script Icon"); #if UNITY_2018_3_OR_NEWER goIcon = EditorGUIUtility.FindTexture("UnityEngine/GameObject Icon"); #else goIcon = EditorGUIUtility.FindTexture("GameObject Icon"); #endif if (goIcon == null) { goIcon = EditorGUIUtility.FindTexture("Prefab Icon"); } materialIcon = EditorGUIUtility.FindTexture("Material Icon"); sceneAssetIcon = EditorGUIUtility.FindTexture("SceneAsset Icon"); viewToolZoomIcon = EditorGUIUtility.FindTexture("d_ViewToolZoom"); Texture2D downArrowTex = (Texture2D)findObject("com.eh.down"); downArrow = new GUIStyle(); downArrow.margin = new RectOffset(0, 0, 3, 0); downArrow.normal.background = downArrowTex; downArrow.fixedWidth = 15; downArrow.fixedHeight = 15; Texture2D upArrowTex = (Texture2D)findObject("com.eh.up"); upArrow = new GUIStyle(); upArrow.margin = new RectOffset(0, 0, 3, 0); upArrow.normal.background = upArrowTex; upArrow.fixedWidth = 15; upArrow.fixedHeight = 15; edit = new GUIStyle(); edit.margin = new RectOffset(1, 4, 3, 0); edit.normal.background = (Texture2D)findObject("com.eh.edit"); edit.fixedWidth = 15; edit.fixedHeight = 15; save = new GUIStyle(); save.margin = new RectOffset(1, 1, 3, 0); save.normal.background = (Texture2D)findObject("com.eh.save"); save.fixedWidth = 15; save.fixedHeight = 15; rename = new GUIStyle(); rename.margin = new RectOffset(1, 1, 3, 0); rename.normal.background = (Texture2D)findObject("com.eh.rename"); rename.fixedWidth = 15; rename.fixedHeight = 15; load = new GUIStyle(); load.margin = new RectOffset(1, 1, 3, 0); load.normal.background = (Texture2D)findObject("com.eh.load"); load.fixedWidth = 15; load.fixedHeight = 15; loadSearch = new GUIStyle(); loadSearch.margin = new RectOffset(1, 5, 3, 0); loadSearch.normal.background = (Texture2D)findObject("com.eh.loadSearch"); loadSearch.fixedWidth = 15; loadSearch.fixedHeight = 15; } }