// Use this as a callback when the login attempt is finished void LoginAttempted(string message) { // Check for Errors if (message.IsAnError()) { Debug.LogError(message); return; } // Try to get the accountID accountId = System.Convert.ToInt32(message); // 5) Download their account Info accountInfo.TryToDownload(accountId, OnDownload); }
void OnGUI() { GUILayout.BeginArea(new Rect(10, 10, Screen.width - 10, Screen.height - 10)); // ------------ BUTTONS ------------------ // Prompt to Download Info from the Database GUILayout.BeginHorizontal(); if (GUILayout.Button("Download Account Info", GUILayout.Width(200))) { guiMessage = "Downloading your info.."; accountInfo.TryToDownload(accountId, AccountInfoDownloaded); } // Prompt to Upload Info to the Database if (GUILayout.Button("Upload Account Info", GUILayout.Width(200))) { string errorMessage = ""; if (!accountInfo.fields.CheckMySQLFields(ref errorMessage)) { Debug.LogError("AccountSystem: Invalid MySQL Field Value:\n" + errorMessage); guiMessage = errorMessage; } else { // If the user set a new password if (tempPasswordVal != "") { Debug.Log("AccountSystem: Updated Password!"); accountInfo.fields.SetFieldValue("password", tempPasswordVal.Hash()); } guiMessage = "Uploading your info.."; accountInfo.TryToUpload(accountId, AccountInfoUploaded); } } GUILayout.EndHorizontal(); GUILayout.Label(" ", GUILayout.Width(100)); if (currentPage == ManagementPage.AccountInfo) { GUILayout.Label("~~~==== Account Management ====~~~", GUILayout.Width(300)); if (GUILayout.Button("Go to Custom Info", GUILayout.Width(200))) { currentPage = ManagementPage.CustomInfo; } // ------------ ACCOUNT INFO ------------------ accountInfo = AccountInfoOnGUI(accountInfo); } else if (currentPage == ManagementPage.CustomInfo) { // ------------ CUSTOM INFO ------------------ // Note that upon altering the CustomInfo class, // this part will seize to work - // Although don't worry, you will still // be able to upload / download and see the custom // Info class in the default inspector GUILayout.Label("~~~==== Custom Info ====~~~", GUILayout.Width(300)); if (GUILayout.Button("Go to Account Management", GUILayout.Width(200))) { currentPage = ManagementPage.AccountInfo; } accountInfo.customInfo = accountInfo.customInfo.CustomInfoOnGUI(); } GUILayout.Label("", GUILayout.Height(10)); GUILayout.Label(guiMessage); // Tutorial #if UNITY_EDITOR GUILayout.Label("", GUILayout.Height(10)); GUILayout.Label("\bHow To Manage your Account:" + "\n1) Alter your Account Info" + "\n2) Alter your Custom Info" + "\n3) Hit Upload" + "\n\nThis message was printed from AS_AccountManagementGUI.cs", GUILayout.Width(500)); #endif GUILayout.EndArea(); }