Example #1
0
        private void SelectDatabase()
        {
            string searchString = "Search...";

            LoginConfigurations[] databases = UnityEditorUtility.FindAssets <LoginConfigurations>();

            UtilityInstanceWindow.ShowWindow("Select Configuration", 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;
                    }
                    databases[i].settings = databases[i].settings.OrderBy(x => x.Order).ToList();

                    GUIStyle style = new GUIStyle("button");
                    style.wordWrap = true;
                    if (GUILayout.Button(AssetDatabase.GetAssetPath(databases[i]), style))
                    {
                        database = databases[i];
                        ResetChildEditors();
                        Show();
                        UtilityInstanceWindow.CloseWindow();
                    }
                }
                GUILayout.FlexibleSpace();
                Color color         = GUI.backgroundColor;
                GUI.backgroundColor = Color.green;
                if (GUILayout.Button("Create"))
                {
                    LoginConfigurations db = AssetCreator.CreateAsset <LoginConfigurations>(true);
                    if (db != null)
                    {
                        ArrayUtility.Add <LoginConfigurations>(ref databases, db);
                    }
                }
                GUI.backgroundColor = color;
            });
        }