public static void OnGUI(Settings settings, GowSettingsEditor settingsEditor)
        {
            if (IsTokenValid(settings.token))
            {
                EditorGUILayout.BeginHorizontal();
                Label(string.Format("Studio: {0}", settings.selectedStudioName));
                if (Button("Select other", 122))
                {
                    settings.selectedGameId   = null;
                    settings.selectedStudioId = null;

                    settingsEditor.SetTab(GowSettingsEditor.GOWSettingsTab.Login);
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                Label(string.Format("Game: {0}", settings.selectedGameName));
                if (Button("Select other", 100))
                {
                    settings.selectedGameId = null;

                    settingsEditor.SetTab(GowSettingsEditor.GOWSettingsTab.Login);
                }
                if (FetchButton())
                {
                    var args = new JsonObject();
                    args.Add("game", settings.selectedGameId);
                    args.Add("token", settings.token);

                    SendRequest("games.get", args, response => {
                        var gameObject = response.GetChild("result");

                        settings.selectedGameId       = gameObject["_id"].ToString();
                        settings.selectedGameName     = gameObject["name"].ToString();
                        settings.selectedGameCategory = gameObject["category"].ToString();
                        settings.gameKey          = gameObject["securityKey"].ToString();
                        settings.androidGameId    = gameObject["androidAppID"].ToString();
                        settings.androidPublicKey = gameObject["androidPublicKey"].ToString();
                    }, error => { });
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                Label(string.Format("Category: {0}", settings.selectedGameCategory));
                EditorGUILayout.EndHorizontal();


                GUILayout.Label(string.Format("Game key: {0}", settings.gameKey));
            }
            else
            {
                settings.gameKey = EditorGUILayout.TextField("Game key", settings.gameKey);
            }
            settings.androidGameId    = EditorGUILayout.TextField("Firebase Sender Id", settings.androidGameId);
            settings.androidPublicKey = EditorGUILayout.TextField("Android Public Key", settings.androidPublicKey);

            SerializedObject serializedSettings = new UnityEditor.SerializedObject(settings);

            settings.autoConfirmPurchase = EditorGUILayout.Toggle("Autoconfirm purchase", settings.autoConfirmPurchase);

            if (settings.autoConfirmPurchase)
            {
                settings.autoConfirmPurchaseWhenError = EditorGUILayout.Toggle("Autoconfirm purchase when error", settings.autoConfirmPurchaseWhenError);
            }

            settings.autoSubscribeToNotifications = EditorGUILayout.Toggle("Autosubscribe to notifications", settings.autoSubscribeToNotifications);

            settings.loggingEnabled = EditorGUILayout.Toggle("Enable logging", settings.loggingEnabled);

            serializedSettings.ApplyModifiedProperties();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(settings);
            }

            // settings.loggingEnabled = EditorGUILayout.Toggle("Enable logging", settings.loggingEnabled);
        }
Beispiel #2
0
        public static void OnGUI(Settings settings, GowSettingsEditor settingsEditor)
        {
            GUIStyle errorStyle = new GUIStyle();

            errorStyle.normal.textColor = Color.red;

            if (IsTokenValid(settings.token))
            {
                EditorGUILayout.BeginHorizontal();
                LabelRight(string.Format("Email: {0}", settings.email));
                if (ButtonLogout())
                {
                    Reset();
                    settings.token                = null;
                    settings.selectedGameId       = null;
                    settings.selectedGameName     = null;
                    settings.selectedGameCategory = null;
                    settings.gameKey              = null;
                    settings.androidGameId        = null;
                    settings.androidPublicKey     = null;
                    _password = null;
                    _studios  = null;
                    _studio   = null;
                    _games    = null;
                    _game     = null;
                    EditorUtility.SetDirty(settings);
                    Undo.RecordObject(settings, settings.name);
                    AssetDatabase.SaveAssets();
                }
                EditorGUILayout.EndHorizontal();
            }

            if (!IsTokenValid(settings.token))
            {
                if (!string.IsNullOrEmpty(_email))
                {
                    _email = _email.Trim();
                }
                _email    = EditorGUILayout.TextField("Email", _email);
                _password = EditorGUILayout.PasswordField("Password", _password);

                if (Button("Login"))
                {
                    if (string.IsNullOrEmpty(_email))
                    {
                        webErrorLine = "Email cannot be empty";
                    }
                    else if (string.IsNullOrEmpty(_password))
                    {
                        webErrorLine = "Password cannot be empty";
                    }
                    else
                    {
                        Login(_email, _password, token => {
                            settings.selectedStudioId = null;
                            settings.selectedGameId   = null;
                            settings.token            = token;
                            settings.email            = _email;
                        }, error => {
                        });
                    }
                }
            }
            else if (_studio == null || string.IsNullOrEmpty(settings.selectedStudioId) || settings.selectedStudioId != _studio.id)
            {
                DrawSelectStudio(settings);
            }
            else if (_game == null || string.IsNullOrEmpty(settings.selectedGameId) || settings.selectedGameId != _game.id)
            {
                DrawSelectStudio(settings);

                DrawSelectGame(settings);
            }
            else
            {
                GUILayout.Label("You logged in");
                GowSettingsEditorSettings.OnGUI(settings, settingsEditor);
            }

            DrawErrorLabel();
        }