| using System.Collections; | 
| using System.Collections.Generic; | 
| using UnityEngine; | 
| using UnityEngine.UI; | 
| using LitJson; | 
|   | 
| public class DebugLogin : MonoBehaviour | 
| { | 
|     public InputField appid; | 
|     public InputField serverId; | 
|     public InputField account; | 
|     public InputField password; | 
|     public InputField platform; | 
|   | 
|     public Toggle isToken; | 
|   | 
|     string appidRecorder { | 
|         get { return LocalSave.GetString("DebugLogin_AppId"); } | 
|         set { LocalSave.SetString("DebugLogin_AppId", value); } | 
|     } | 
|   | 
|     string serverIdRecorder { | 
|         get { return LocalSave.GetString("DebugLogin_ServerId"); } | 
|         set { LocalSave.SetString("DebugLogin_ServerId", value); } | 
|     } | 
|   | 
|   | 
|     string accountRecorder { | 
|         get { return LocalSave.GetString("DebugLogin_Account"); } | 
|         set { LocalSave.SetString("DebugLogin_Account", value); } | 
|     } | 
|   | 
|     string passwordRecorder { | 
|         get { return LocalSave.GetString("DebugLogin_Password"); } | 
|         set { LocalSave.SetString("DebugLogin_Password", value); } | 
|     } | 
|   | 
|     int platformRecorder { | 
|         get { | 
|             return LocalSave.GetInt("DebugLoging_Platform", 1); | 
|         } | 
|         set { | 
|             LocalSave.SetInt("DebugLoging_Platform", value); | 
|         } | 
|     } | 
|   | 
|     bool istokenRecorder { | 
|         get { return LocalSave.GetBool("DebugLogin_IsToken", false); } | 
|         set { LocalSave.SetBool("DebugLogin_IsToken", value); } | 
|     } | 
|   | 
|     private void OnEnable() | 
|     { | 
|         appid.text = appidRecorder; | 
|         serverId.text = serverIdRecorder; | 
|         account.text = accountRecorder; | 
|         password.text = passwordRecorder; | 
|         platform.text = platformRecorder.ToString(); | 
|         isToken.isOn = istokenRecorder; | 
|     } | 
|   | 
|     public void Login() | 
|     { | 
|         appidRecorder = appid.text; | 
|         serverIdRecorder = serverId.text; | 
|         accountRecorder = account.text; | 
|         passwordRecorder = password.text; | 
|         var platformTemp = 0; | 
|         int.TryParse(platform.text, out platformTemp); | 
|         platformRecorder = platformTemp; | 
|         istokenRecorder = isToken.isOn; | 
|   | 
|         if (!string.IsNullOrEmpty(appid.text)) | 
|         { | 
|             bool needRestore = VersionConfig.Get().m_AppId != appid.text; | 
|             VersionConfig.Get().m_AppId = appid.text; | 
| #if UNITY_EDITOR | 
|             //debug登录后第二次启动默认恢复test | 
|             if (needRestore) | 
|                 LocalSave.SetBool("RestoreTest", true); | 
| #endif | 
|         } | 
|   | 
|         SDKUtils.Instance.ChannelPlatform = (SDKUtils.E_ChannelPlatform)int.Parse(platform.text); | 
|   | 
|         if (isToken.isOn) | 
|         { | 
|             // var loginModel = ModelCenter.Instance.GetModel<LoginModel>(); | 
|             // LoginManager.Instance.sdkLoginResult = new SDKUtils.FP_LoginOk() | 
|             // { | 
|             //     account = account.text, | 
|             //     token = password.text, | 
|             //     tokenExpire = "1519750743000", | 
|             //     phone = 0, | 
|             //     accountID = 1000 | 
|             // }; | 
|   | 
|             LoginManager.Instance.sdkLogined = true; | 
|             var ip = ServerListCenter.Instance.currentServer.region_domain; | 
|             var port = ServerListCenter.Instance.currentServer.login_port; | 
|             var gamePort = ServerListCenter.Instance.currentServer.game_port; | 
|             if (!string.IsNullOrEmpty(serverId.text)) | 
|             { | 
|                 var serverData = ServerListCenter.Instance.currentServer; | 
|                 serverData.region_flag = int.Parse(serverId.text); | 
|                 ServerListCenter.Instance.currentServer = serverData; | 
|             } | 
|   | 
|             LoginManager.Instance.AccountLogin(ip, port, gamePort); | 
|         } | 
|   | 
|     } | 
|   | 
|   | 
|   | 
|     struct SDKLoginResult | 
|     { | 
|         public string errorcode; | 
|         public string errordesc; | 
|         public string token; | 
|         public string account; | 
|         public string token_expire; | 
|         public string phone; | 
|         public string account_id; | 
|     } | 
| } |