public static void SaveExistingTemplate(XcodeSerializer template) { int index = elements.IndexOf(template); if (index == -1) { return; } EditorPrefs.SetString(keyPrefix + index, template.ToString()); }
void OnGUI() { if (serializer == null) { OnEnable(); } scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition); { serializer.OnGUI(); EditorGUILayout.Space(); templateName = EditorGUILayout.TextField("Template name: ", templateName); if (GUILayout.Button("Save as Template")) { XcodeSerializer templateSerializer = XcodeSerializer.CreateInstance(serializer.ToString(), true); templateSerializer.name = templateName; XcodeTemplateManager.SaveTemplate(templateSerializer); } EditorGUILayout.Space(); for (int i = 0; i < templates.Count; i++) { EditorGUILayout.BeginHorizontal(); { templates[i].display = EditorGUILayout.Foldout(templates[i].display, templates[i].name); if (GUILayout.Button("Import", GUILayout.Width(50))) { serializer.Merge(templates[i]); } if (GUILayout.Button("Delete", GUILayout.Width(50))) { XcodeTemplateManager.DeleteTemplate(templates[i--]); continue; } } EditorGUILayout.EndHorizontal(); BBGuiHelper.BeginIndent(); { if (templates[i].display) { EditorGUILayout.BeginHorizontal(); { EditorGUILayout.LabelField("Name: ", GUILayout.Width(75)); templates[i].name = EditorGUILayout.TextField(templates[i].name); } EditorGUILayout.EndHorizontal(); templates[i].OnGUI(); } } BBGuiHelper.EndIndent(); } } EditorGUILayout.EndScrollView(); //Repaint on Undo if (Event.current.type == EventType.ValidateCommand) { switch (Event.current.commandName) { case "UndoRedoPerformed": this.Repaint(); break; } } }
public static void SaveTemplate(XcodeSerializer data) { elements.Add(data); EditorPrefs.SetString(keyPrefix + (elements.Count - 1), data.ToString()); }