From 32bd6f3f41391717f676d0e4c88ca7f176ad7f45 Mon Sep 17 00:00:00 2001 From: Ferhat TEPE Date: Sat, 12 Aug 2023 15:05:03 +0000 Subject: [PATCH] feat: import export feature --- .../PreferencesEditorWindow.cs | 279 +++++++++++++----- 1 file changed, 205 insertions(+), 74 deletions(-) diff --git a/Packages/PlayerPrefsEditor/Editor/PreferencesEditor/PreferencesEditorWindow.cs b/Packages/PlayerPrefsEditor/Editor/PreferencesEditor/PreferencesEditorWindow.cs index 1e3222c..bf910e7 100644 --- a/Packages/PlayerPrefsEditor/Editor/PreferencesEditor/PreferencesEditorWindow.cs +++ b/Packages/PlayerPrefsEditor/Editor/PreferencesEditor/PreferencesEditorWindow.cs @@ -6,8 +6,11 @@ using System.IO; using System.Linq; using System.Collections.Generic; +using System.Text; using BgTools.Utils; using BgTools.Dialogs; +using Newtonsoft.Json; +using Object = UnityEngine.Object; #if (UNITY_EDITOR_LINUX || UNITY_EDITOR_OSX) using System.Text; @@ -18,9 +21,11 @@ namespace BgTools.PlayerPrefsEditor { public class PreferencesEditorWindow : EditorWindow { -#region ErrorValues + #region ErrorValues + private readonly int ERROR_VALUE_INT = int.MinValue; private readonly string ERROR_VALUE_STR = ""; + #endregion //ErrorValues private enum PreferencesEntrySortOrder @@ -63,9 +68,16 @@ private enum PreferencesEntrySortOrder private readonly List prefKeyValidatorList = new List() { - new TextValidator(TextValidator.ErrorType.Error, @"Invalid character detected. Only letters, numbers, space and ,.;:<>_|!§$%&/()=?*+~#-]+$ are allowed", @"(^$)|(^[a-zA-Z0-9 ,.;:<>_|!§$%&/()=?*+~#-]+$)"), - new TextValidator(TextValidator.ErrorType.Warning, @"The given key already exist. The existing entry would be overwritten!", (key) => { return !PlayerPrefs.HasKey(key); }) + new TextValidator(TextValidator.ErrorType.Error, + @"Invalid character detected. Only letters, numbers, space and ,.;:<>_|!§$%&/()=?*+~#-]+$ are allowed", + @"(^$)|(^[a-zA-Z0-9 ,.;:<>_|!§$%&/()=?*+~#-]+$)"), + new TextValidator(TextValidator.ErrorType.Warning, + @"The given key already exist. The existing entry would be overwritten!", + (key) => { return !PlayerPrefs.HasKey(key); }) }; + private string _prefHolder; + private int _exportFileIndex; + private Object importObject; #if UNITY_EDITOR_LINUX private readonly char[] invalidFilenameChars = { '"', '\\', '*', '/', ':', '<', '>', '?', '|' }; @@ -87,25 +99,28 @@ static void ShowWindow() private void OnEnable() { #if UNITY_EDITOR_WIN - pathToPrefs = @"SOFTWARE\Unity\UnityEditor\" + PlayerSettings.companyName + @"\" + PlayerSettings.productName; + pathToPrefs = @"SOFTWARE\Unity\UnityEditor\" + PlayerSettings.companyName + @"\" + + PlayerSettings.productName; platformPathPrefix = @""; entryAccessor = new WindowsPrefStorage(pathToPrefs); #elif UNITY_EDITOR_OSX - pathToPrefs = @"Library/Preferences/unity." + MakeValidFileName(PlayerSettings.companyName) + "." + MakeValidFileName(PlayerSettings.productName) + ".plist"; + pathToPrefs = + @"Library/Preferences/unity." + MakeValidFileName(PlayerSettings.companyName) + "." + MakeValidFileName(PlayerSettings.productName) + ".plist"; entryAccessor = new MacPrefStorage(pathToPrefs); entryAccessor.StartLoadingDelegate = () => { showLoadingIndicatorOverlay = true; }; entryAccessor.StopLoadingDelegate = () => { showLoadingIndicatorOverlay = false; }; #elif UNITY_EDITOR_LINUX - pathToPrefs = @".config/unity3d/" + MakeValidFileName(PlayerSettings.companyName) + "/" + MakeValidFileName(PlayerSettings.productName) + "/prefs"; + pathToPrefs = + @".config/unity3d/" + MakeValidFileName(PlayerSettings.companyName) + "/" + MakeValidFileName(PlayerSettings.productName) + "/prefs"; entryAccessor = new LinuxPrefStorage(pathToPrefs); #endif entryAccessor.PrefEntryChangedDelegate = () => { updateView = true; }; monitoring = EditorPrefs.GetBool("BGTools.PlayerPrefsEditor.WatchingForChanges", true); - if(monitoring) + if (monitoring) entryAccessor.StartMonitoring(); - sortOrder = (PreferencesEntrySortOrder) EditorPrefs.GetInt("BGTools.PlayerPrefsEditor.SortOrder", 0); + sortOrder = (PreferencesEntrySortOrder)EditorPrefs.GetInt("BGTools.PlayerPrefsEditor.SortOrder", 0); searchfield = new MySearchField(); searchfield.DropdownSelectionDelegate = () => { PrepareData(); }; @@ -161,15 +176,15 @@ private void InitReorderedList() serializedObject = new SerializedObject(prefEntryHolder); } - userDefList = new ReorderableList(serializedObject, serializedObject.FindProperty("userDefList"), false, true, true, true); - unityDefList = new ReorderableList(serializedObject, serializedObject.FindProperty("unityDefList"), false, true, false, false); + userDefList = new ReorderableList(serializedObject, serializedObject.FindProperty("userDefList"), false, + true, true, true); + unityDefList = new ReorderableList(serializedObject, serializedObject.FindProperty("unityDefList"), false, + true, false, false); - relSpliterPos = EditorPrefs.GetFloat("BGTools.PlayerPrefsEditor.RelativeSpliterPosition", 100 / position.width); + relSpliterPos = + EditorPrefs.GetFloat("BGTools.PlayerPrefsEditor.RelativeSpliterPosition", 100 / position.width); - userDefList.drawHeaderCallback = (Rect rect) => - { - EditorGUI.LabelField(rect, "User defined"); - }; + userDefList.drawHeaderCallback = (Rect rect) => { EditorGUI.LabelField(rect, "User defined"); }; userDefList.drawElementBackgroundCallback = OnDrawElementBackgroundCallback; userDefList.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => { @@ -202,22 +217,31 @@ private void InitReorderedList() EditorGUI.BeginChangeCheck(); string prefKeyName = key.stringValue; - EditorGUI.LabelField(new Rect(rect.x, rect.y, spliterPos - 1, EditorGUIUtility.singleLineHeight), new GUIContent(prefKeyName, prefKeyName)); + EditorGUI.LabelField(new Rect(rect.x, rect.y, spliterPos - 1, EditorGUIUtility.singleLineHeight), + new GUIContent(prefKeyName, prefKeyName)); GUI.enabled = false; - EditorGUI.EnumPopup(new Rect(rect.x + spliterPos + 1, rect.y, 60, EditorGUIUtility.singleLineHeight), (PreferenceEntry.PrefTypes)type.enumValueIndex); + EditorGUI.EnumPopup(new Rect(rect.x + spliterPos + 1, rect.y, 60, EditorGUIUtility.singleLineHeight), + (PreferenceEntry.PrefTypes)type.enumValueIndex); GUI.enabled = !showLoadingIndicatorOverlay; switch ((PreferenceEntry.PrefTypes)type.enumValueIndex) { case PreferenceEntry.PrefTypes.Float: - EditorGUI.DelayedFloatField(new Rect(rect.x + spliterPos + 62, rect.y, rect.width - spliterPos - 60, EditorGUIUtility.singleLineHeight), value, GUIContent.none); + EditorGUI.DelayedFloatField( + new Rect(rect.x + spliterPos + 62, rect.y, rect.width - spliterPos - 60, + EditorGUIUtility.singleLineHeight), value, GUIContent.none); break; case PreferenceEntry.PrefTypes.Int: - EditorGUI.DelayedIntField(new Rect(rect.x + spliterPos + 62, rect.y, rect.width - spliterPos - 60, EditorGUIUtility.singleLineHeight), value, GUIContent.none); + EditorGUI.DelayedIntField( + new Rect(rect.x + spliterPos + 62, rect.y, rect.width - spliterPos - 60, + EditorGUIUtility.singleLineHeight), value, GUIContent.none); break; case PreferenceEntry.PrefTypes.String: - EditorGUI.DelayedTextField(new Rect(rect.x + spliterPos + 62, rect.y, rect.width - spliterPos - 60, EditorGUIUtility.singleLineHeight), value, GUIContent.none); + EditorGUI.DelayedTextField( + new Rect(rect.x + spliterPos + 62, rect.y, rect.width - spliterPos - 60, + EditorGUIUtility.singleLineHeight), value, GUIContent.none); break; } + if (EditorGUI.EndChangeCheck()) { entryAccessor.IgnoreNextChange(); @@ -243,8 +267,11 @@ private void InitReorderedList() userDefList.ReleaseKeyboardFocus(); unityDefList.ReleaseKeyboardFocus(); - string prefKey = l.serializedProperty.GetArrayElementAtIndex(l.index).FindPropertyRelative("m_key").stringValue; - if (EditorUtility.DisplayDialog("Warning!", $"Are you sure you want to delete this entry from PlayerPrefs?\n\nEntry: {prefKey}", "Yes", "No")) + string prefKey = l.serializedProperty.GetArrayElementAtIndex(l.index).FindPropertyRelative("m_key") + .stringValue; + if (EditorUtility.DisplayDialog("Warning!", + $"Are you sure you want to delete this entry from PlayerPrefs?\n\nEntry: {prefKey}", "Yes", + "No")) { entryAccessor.IgnoreNextChange(); @@ -263,34 +290,36 @@ private void InitReorderedList() { menu.AddItem(new GUIContent(type.ToString()), false, () => { - TextFieldDialog.OpenDialog("Create new property", "Key for the new property:", prefKeyValidatorList, (key) => { - - entryAccessor.IgnoreNextChange(); - - switch (type) + TextFieldDialog.OpenDialog("Create new property", "Key for the new property:", + prefKeyValidatorList, (key) => { - case PreferenceEntry.PrefTypes.Float: - PlayerPrefs.SetFloat(key, 0.0f); + entryAccessor.IgnoreNextChange(); + + switch (type) + { + case PreferenceEntry.PrefTypes.Float: + PlayerPrefs.SetFloat(key, 0.0f); - break; - case PreferenceEntry.PrefTypes.Int: - PlayerPrefs.SetInt(key, 0); + break; + case PreferenceEntry.PrefTypes.Int: + PlayerPrefs.SetInt(key, 0); - break; - case PreferenceEntry.PrefTypes.String: - PlayerPrefs.SetString(key, string.Empty); + break; + case PreferenceEntry.PrefTypes.String: + PlayerPrefs.SetString(key, string.Empty); - break; - } - PlayerPrefs.Save(); + break; + } - PrepareData(); + PlayerPrefs.Save(); - Focus(); - }, this); + PrepareData(); + Focus(); + }, this); }); } + menu.ShowAsContext(); }; @@ -325,27 +354,33 @@ private void InitReorderedList() GUI.enabled = false; string prefKeyName = key.stringValue; - EditorGUI.LabelField(new Rect(rect.x, rect.y, spliterPos - 1, EditorGUIUtility.singleLineHeight), new GUIContent(prefKeyName, prefKeyName)); - EditorGUI.EnumPopup(new Rect(rect.x + spliterPos + 1, rect.y, 60, EditorGUIUtility.singleLineHeight), (PreferenceEntry.PrefTypes)type.enumValueIndex); + EditorGUI.LabelField(new Rect(rect.x, rect.y, spliterPos - 1, EditorGUIUtility.singleLineHeight), + new GUIContent(prefKeyName, prefKeyName)); + EditorGUI.EnumPopup(new Rect(rect.x + spliterPos + 1, rect.y, 60, EditorGUIUtility.singleLineHeight), + (PreferenceEntry.PrefTypes)type.enumValueIndex); switch ((PreferenceEntry.PrefTypes)type.enumValueIndex) { case PreferenceEntry.PrefTypes.Float: - EditorGUI.DelayedFloatField(new Rect(rect.x + spliterPos + 62, rect.y, rect.width - spliterPos - 60, EditorGUIUtility.singleLineHeight), value, GUIContent.none); + EditorGUI.DelayedFloatField( + new Rect(rect.x + spliterPos + 62, rect.y, rect.width - spliterPos - 60, + EditorGUIUtility.singleLineHeight), value, GUIContent.none); break; case PreferenceEntry.PrefTypes.Int: - EditorGUI.DelayedIntField(new Rect(rect.x + spliterPos + 62, rect.y, rect.width - spliterPos - 60, EditorGUIUtility.singleLineHeight), value, GUIContent.none); + EditorGUI.DelayedIntField( + new Rect(rect.x + spliterPos + 62, rect.y, rect.width - spliterPos - 60, + EditorGUIUtility.singleLineHeight), value, GUIContent.none); break; case PreferenceEntry.PrefTypes.String: - EditorGUI.DelayedTextField(new Rect(rect.x + spliterPos + 62, rect.y, rect.width - spliterPos - 60, EditorGUIUtility.singleLineHeight), value, GUIContent.none); + EditorGUI.DelayedTextField( + new Rect(rect.x + spliterPos + 62, rect.y, rect.width - spliterPos - 60, + EditorGUIUtility.singleLineHeight), value, GUIContent.none); break; } + GUI.enabled = !showLoadingIndicatorOverlay; }; - unityDefList.drawHeaderCallback = (Rect rect) => - { - EditorGUI.LabelField(rect, "Unity defined"); - }; + unityDefList.drawHeaderCallback = (Rect rect) => { EditorGUI.LabelField(rect, "Unity defined"); }; } private void OnDrawElementBackgroundCallback(Rect rect, int index, bool isActive, bool isFocused) @@ -361,14 +396,16 @@ private void OnDrawElementBackgroundCallback(Rect rect, int index, bool isActive { moveSplitterPos = true; } - if(moveSplitterPos) + + if (moveSplitterPos) { - if (Event.current.mousePosition.x > 100 && Event.current.mousePosition.x 100 && Event.current.mousePosition.x < rect.width - 120) { relSpliterPos = Event.current.mousePosition.x / rect.width; Repaint(); } } + if (Event.current.type == EventType.MouseUp) { moveSplitterPos = false; @@ -424,17 +461,19 @@ void OnGUI() if (GUILayout.Button(sortOrderContent, EditorStyles.toolbarButton)) { - sortOrder++; - if((int) sortOrder >= Enum.GetValues(typeof(PreferencesEntrySortOrder)).Length) + if ((int)sortOrder >= Enum.GetValues(typeof(PreferencesEntrySortOrder)).Length) { sortOrder = 0; } - EditorPrefs.SetInt("BGTools.PlayerPrefsEditor.SortOrder", (int) sortOrder); + + EditorPrefs.SetInt("BGTools.PlayerPrefsEditor.SortOrder", (int)sortOrder); PrepareData(false); } - GUIContent watcherContent = (entryAccessor.IsMonitoring()) ? new GUIContent(ImageManager.Watching, "Watching changes") : new GUIContent(ImageManager.NotWatching, "Not watching changes"); + GUIContent watcherContent = (entryAccessor.IsMonitoring()) + ? new GUIContent(ImageManager.Watching, "Watching changes") + : new GUIContent(ImageManager.NotWatching, "Not watching changes"); if (GUILayout.Button(watcherContent, EditorStyles.toolbarButton)) { monitoring = !monitoring; @@ -448,20 +487,90 @@ void OnGUI() Repaint(); } + if (GUILayout.Button(new GUIContent(ImageManager.Refresh, "Refresh"), EditorStyles.toolbarButton)) { PlayerPrefs.Save(); PrepareData(); } + + if (GUILayout.Button(new GUIContent(ImageManager.Trash, "Delete all"), EditorStyles.toolbarButton)) { - if (EditorUtility.DisplayDialog("Warning!", "Are you sure you want to delete ALL entries from PlayerPrefs?\n\nUse with caution! Unity defined keys are affected too.", "Yes", "No")) + if (EditorUtility.DisplayDialog("Warning!", + "Are you sure you want to delete ALL entries from PlayerPrefs?\n\nUse with caution! Unity defined keys are affected too.", + "Yes", "No")) { PlayerPrefs.DeleteAll(); PrepareData(); GUIUtility.ExitGUI(); } } + + if (GUILayout.Button(new GUIContent("Export"), EditorStyles.toolbarButton)) + { + _exportFileIndex++; + _prefHolder = JsonConvert.SerializeObject(prefEntryHolder.userDefList); + var fileName = Path.Combine(Application.dataPath, $"playerprefs{_exportFileIndex}.txt"); + try + { + if (File.Exists(fileName)) + { + File.Delete(fileName); + } + + using FileStream fs = File.Create(fileName); + var data = new UTF8Encoding(true).GetBytes(_prefHolder); + fs.Write(data, 0, data.Length); + fs.Dispose(); + fs.Close(); + + AssetDatabase.Refresh(); + Debug.LogError($"Export Completed! Path:{fileName}"); + } + catch (Exception Ex) + { + Debug.LogError($"Export Fail!"); + Debug.LogError(Ex.ToString()); + } + } + + if (GUILayout.Button(new GUIContent("Import"), EditorStyles.toolbarButton)) + { + if (importObject == null) + { + Debug.LogError("Import file is missing!!"); + GUIUtility.ExitGUI(); + } + + var asset = importObject as TextAsset; + var importHolder = JsonConvert.DeserializeObject>(asset.text); + PlayerPrefs.DeleteAll(); + + foreach (var entry in importHolder) + { + switch (entry.m_typeSelection) + { + case PreferenceEntry.PrefTypes.Float: + PlayerPrefs.SetFloat(entry.m_key, entry.m_floatValue); + break; + case PreferenceEntry.PrefTypes.Int: + PlayerPrefs.SetInt(entry.m_key, entry.m_intValue); + break; + case PreferenceEntry.PrefTypes.String: + PlayerPrefs.SetString(entry.m_key, entry.m_strValue); + break; + } + } + + + PlayerPrefs.Save(); + PrepareData(); + } + + importObject = EditorGUILayout.ObjectField(importObject, typeof(Object)); + + EditorGUIUtility.SetIconSize(new Vector2(0.0f, 0.0f)); GUILayout.EndHorizontal(); @@ -469,7 +578,8 @@ void OnGUI() GUILayout.BeginHorizontal(); GUILayout.Box(ImageManager.GetOsIcon(), Styles.icon); - GUILayout.TextField(platformPathPrefix + Path.DirectorySeparatorChar + pathToPrefs, GUILayout.MinWidth(200)); + GUILayout.TextField(platformPathPrefix + Path.DirectorySeparatorChar + pathToPrefs, + GUILayout.MinWidth(200)); GUILayout.EndHorizontal(); @@ -485,6 +595,7 @@ void OnGUI() { unityDefList.DoLayoutList(); } + GUILayout.EndScrollView(); GUILayout.EndVertical(); @@ -492,7 +603,8 @@ void OnGUI() if (showLoadingIndicatorOverlay) { - GUILayout.BeginArea(new Rect(position.size.x * 0.5f - 30, position.size.y * 0.5f - 25, 60, 50), GUI.skin.box); + GUILayout.BeginArea(new Rect(position.size.x * 0.5f - 30, position.size.y * 0.5f - 25, 60, 50), + GUI.skin.box); GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); @@ -514,7 +626,8 @@ void OnGUI() GUI.contentColor = defaultColor; } catch (InvalidOperationException) - { } + { + } } private void PrepareData(bool reloadKeys = true) @@ -532,7 +645,8 @@ private void PrepareData(bool reloadKeys = true) private void CreatePrefEntries(string[] keySource, ref List listDest) { - if (!string.IsNullOrEmpty(searchTxt) && searchfield.SearchMode == MySearchField.SearchModePreferencesEditorWindow.Key) + if (!string.IsNullOrEmpty(searchTxt) && + searchfield.SearchMode == MySearchField.SearchModePreferencesEditorWindow.Key) { keySource = keySource.Where((keyEntry) => keyEntry.ToLower().Contains(searchTxt.ToLower())).ToArray(); } @@ -571,12 +685,15 @@ private void CreatePrefEntries(string[] keySource, ref List lis } } - if (!string.IsNullOrEmpty(searchTxt) && searchfield.SearchMode == MySearchField.SearchModePreferencesEditorWindow.Value) + if (!string.IsNullOrEmpty(searchTxt) && + searchfield.SearchMode == MySearchField.SearchModePreferencesEditorWindow.Value) { - listDest = listDest.Where((preferenceEntry) => preferenceEntry.ValueAsString().ToLower().Contains(searchTxt.ToLower())).ToList(); + listDest = listDest + .Where((preferenceEntry) => preferenceEntry.ValueAsString().ToLower().Contains(searchTxt.ToLower())) + .ToList(); } - switch(sortOrder) + switch (sortOrder) { case PreferencesEntrySortOrder.Asscending: listDest.Sort((PreferenceEntry x, PreferenceEntry y) => { return x.m_key.CompareTo(y.m_key); }); @@ -595,8 +712,8 @@ private void LoadKeys(out string[] userDef, out string[] unityDef, bool reloadKe // Seperate keys int unity defined and user defined Dictionary> groups = keys - .GroupBy( (key) => key.StartsWith("unity.") || key.StartsWith("UnityGraphicsQuality") ) - .ToDictionary( (g) => g.Key, (g) => g.ToList() ); + .GroupBy((key) => key.StartsWith("unity.") || key.StartsWith("UnityGraphicsQuality")) + .ToDictionary((g) => g.Key, (g) => g.ToList()); unityDef = (groups.ContainsKey(true)) ? groups[true].ToArray() : new string[0]; userDef = (groups.ContainsKey(false)) ? groups[false].ToArray() : new string[0]; @@ -610,6 +727,7 @@ private SerializedProperty GetUserDefListElementAtIndex(int index, SerializedPro { userDefListCache[index] = ListProperty.GetArrayElementAtIndex(index); } + return userDefListCache[index]; } @@ -641,7 +759,11 @@ private string MakeValidFileName(string unsafeFileName) public class MySearchField : SearchField { - public enum SearchModePreferencesEditorWindow { Key, Value } + public enum SearchModePreferencesEditorWindow + { + Key, + Value + } public SearchModePreferencesEditorWindow SearchMode { get; private set; } @@ -663,12 +785,14 @@ public enum SearchModePreferencesEditorWindow { Key, Value } { void OnDropdownSelection(object parameter) { - SearchMode = (SearchModePreferencesEditorWindow) Enum.Parse(typeof(SearchModePreferencesEditorWindow), parameter.ToString()); + SearchMode = (SearchModePreferencesEditorWindow)Enum.Parse(typeof(SearchModePreferencesEditorWindow), + parameter.ToString()); DropdownSelectionDelegate(); } GenericMenu menu = new GenericMenu(); - foreach(SearchModePreferencesEditorWindow EnumIt in Enum.GetValues(typeof(SearchModePreferencesEditorWindow))) + foreach (SearchModePreferencesEditorWindow EnumIt in Enum.GetValues( + typeof(SearchModePreferencesEditorWindow))) { String EnumName = Enum.GetName(typeof(SearchModePreferencesEditorWindow), EnumIt); menu.AddItem(new GUIContent(EnumName), SearchMode == EnumIt, OnDropdownSelection, EnumName); @@ -683,18 +807,25 @@ void OnDropdownSelection(object parameter) // Render additional images GUIStyle ContexMenuOverlayStyle = GUIStyle.none; ContexMenuOverlayStyle.contentOffset = new Vector2(9, 5); - GUI.Box(new Rect(rect.x, rect.y, 5, 5), EditorGUIUtility.IconContent("d_ProfilerTimelineDigDownArrow@2x"), ContexMenuOverlayStyle); + GUI.Box(new Rect(rect.x, rect.y, 5, 5), EditorGUIUtility.IconContent("d_ProfilerTimelineDigDownArrow@2x"), + ContexMenuOverlayStyle); if (!HasFocus() && String.IsNullOrEmpty(text)) { GUI.enabled = false; - GUI.Label(new Rect(rect.x + 14, rect.y, 40, rect.height), Enum.GetName(typeof(SearchModePreferencesEditorWindow), SearchMode)); + GUI.Label(new Rect(rect.x + 14, rect.y, 40, rect.height), + Enum.GetName(typeof(SearchModePreferencesEditorWindow), SearchMode)); GUI.enabled = true; } + ContexMenuOverlayStyle.contentOffset = new Vector2(); return result; } - public new string OnToolbarGUI(string text, params GUILayoutOption[] options) => this.OnToolbarGUI(GUILayoutUtility.GetRect(29f, 200f, 18f, 18f, EditorStyles.toolbarSearchField, options), text); - public new string OnToolbarGUI(Rect rect, string text) => this.OnGUI(rect, text, EditorStyles.toolbarSearchField, EditorStyles.toolbarButton, EditorStyles.toolbarButton); -} + public new string OnToolbarGUI(string text, params GUILayoutOption[] options) => + this.OnToolbarGUI(GUILayoutUtility.GetRect(29f, 200f, 18f, 18f, EditorStyles.toolbarSearchField, options), + text); + + public new string OnToolbarGUI(Rect rect, string text) => this.OnGUI(rect, text, EditorStyles.toolbarSearchField, + EditorStyles.toolbarButton, EditorStyles.toolbarButton); +} \ No newline at end of file