private void OnGUI() { GUILayout.Label("Log style", EditorStyles.boldLabel); _fontSize = EditorGUILayout.IntField("Font size", _fontSize); _classColor = EditorGUILayout.ColorField("Class color", _classColor); _methodColor = EditorGUILayout.ColorField("Method color", _methodColor); _messageColor = EditorGUILayout.ColorField("Message color", _messageColor); _dataColor = EditorGUILayout.ColorField("Data color", _dataColor); if (GUILayout.Button("Save to EditorPrefs")) { SaveStyle(); Epilog.Print("Color switched"); } if (GUILayout.Button("Save to file")) { EditorUtility.SaveFilePanel("Save style data to file", @"C:\Users\vladimir_fly\Downloads\", "style", "epilog"); } if (GUILayout.Button("Load from EditorPrefs")) { Deserialize(); } if (GUILayout.Button("Load from file")) { EditorUtility.OpenFilePanel("Load style data from file", @"C:\Users\vladimir_fly\Downloads\", "epilog"); } }
private void Deserialize() { var formatter = new BinaryFormatter(); using (var fs = new FileStream(@"C:\Users\vladimir_fly\Downloads\style.epilog", FileMode.OpenOrCreate)) { var style = (Style)formatter.Deserialize(fs); Epilog.SetStyle(style); Epilog.Print("deserialized", style.FontSize, style.ClassColor, style.MessageColor, style.MessageColor, style.DataColor); } }
private void SaveToFile() { var style = Epilog.Style; var formatter = new BinaryFormatter(); using (var fs = new FileStream(@"C:\Users\vladimir_fly\Downloads\style.epilog", FileMode.OpenOrCreate)) { formatter.Serialize(fs, style); Epilog.Print("serialized"); } }