public static void Initialize() { _tempDatabasesPath = DatabaseUtilities.DatabasesPath; _tempEnumsPath = DatabaseUtilities.DatabaseEnumsPath; DatabasesWindow window = (DatabasesWindow)GetWindow(typeof(DatabasesWindow)); window.titleContent = new GUIContent("Databases"); window.Show(); }
//Called by Unity // ReSharper disable once InconsistentNaming // ReSharper disable once UnusedMember.Local private void OnGUI() { Color defaultColor = GUI.backgroundColor; EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); { GUILayout.Label("Databases Overview", EditorStyles.boldLabel); if (GUILayout.Button("", new GUIStyle(GUI.skin.FindStyle("OL Plus")), GUILayout.Width(20))) { DatabasesWindow.Initialize(); } } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); if (AllDatabases.Length <= 0) { EditorGUILayout.LabelField("No databases found ..."); } _scrollPos = EditorGUILayout.BeginScrollView(_scrollPos); { if (AllDatabases != null) { foreach (Database database in AllDatabases.OrderBy(t => t.Name)) { EditorGUILayout.BeginHorizontal(); { var temp = database; if (AllDatabases.Select(t => t.Name).Count(t => t == temp.Name) > 1) { GUI.backgroundColor = new Color(1, 0.3f, 0.3f); } if (GUILayout.Button(database.Name)) { DatabaseWindow.CurrentDatabaseIndex = Array.IndexOf(AllDatabases, database); DatabaseWindow.Initialize(); } GUI.backgroundColor = defaultColor; if (GUILayout.Button("X", GUILayout.Width(40)) && EditorUtility.DisplayDialog("Detete " + database.Name, string.Format("Do you want to delete the database: {0}?", database.Name) , "Yes", "Cancel")) { DatabaseWriter.RemoveDatabase(database); _allDatabases = null; } } EditorGUILayout.EndHorizontal(); } } } EditorGUILayout.EndScrollView(); CreateButton(); GUI.backgroundColor = defaultColor; }