public static UtilityWindow ShowWindow(string title, Vector2 size, Action onGUI, Action onClose) { UtilityWindow window = EditorWindow.GetWindow <UtilityWindow>(true, title); window.minSize = size; window.onGUI = onGUI; window.onClose = onClose; return(window); }
protected virtual void SelectDatabase() { string searchString = "Search..."; T[] databases = UnityEditorUtility.GetAssetsOfType <T>(".asset"); UtilityWindow.ShowWindow("Select Settings", delegate() { searchString = UnityEditorUtility.SearchField(searchString); for (int i = 0; i < databases.Length; i++) { if (!string.IsNullOrEmpty(searchString) && !searchString.Equals("Search...") && !databases[i].name.Contains(searchString)) { continue; } GUIStyle style = new GUIStyle("button"); style.wordWrap = true; if (GUILayout.Button(AssetDatabase.GetAssetPath(databases[i]), style)) { database = databases[i]; ResetChildEditors(); Show(); UtilityWindow.CloseWindow(); } } GUILayout.FlexibleSpace(); Color color = GUI.backgroundColor; GUI.backgroundColor = Color.green; if (GUILayout.Button("Create")) { T db = AssetCreator.CreateAsset <T>(true); if (db != null) { ArrayUtility.Add <T>(ref databases, db); } } GUI.backgroundColor = color; }); }
private void OnEnable() { instance = this; }