From 7a5e4598f2e9f348f96af3ee6109115fb0d48a6b Mon Sep 17 00:00:00 2001
From: client_Wu Xijin <364452445@qq.com>
Date: 星期四, 27 六月 2019 14:20:51 +0800
Subject: [PATCH] 3335 添加自动登录工具

---
 System/Debug/DebugUtility.cs |   55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 55 insertions(+), 0 deletions(-)

diff --git a/System/Debug/DebugUtility.cs b/System/Debug/DebugUtility.cs
index 3566c18..8ce7eb3 100644
--- a/System/Debug/DebugUtility.cs
+++ b/System/Debug/DebugUtility.cs
@@ -4,6 +4,7 @@
 using Snxxz.UI;
 using LitJson;
 using System.IO;
+using UnityEngine.UI;
 
 [XLua.LuaCallCSharp]
 public class DebugUtility : Singleton<DebugUtility>
@@ -30,6 +31,8 @@
     public int debugBranch = -1;
 
     public bool isWhiteListAccount { get; private set; }
+
+    public bool autoLogin { get; private set; }
 
     public void Init()
     {
@@ -75,6 +78,58 @@
             DebugEx.EnableLogError = false;
             DebugEx.EnableNetLog = false;
         }
+
+        autoLogin = Resources.Load<TextAsset>("AutoLogin") != null;
+        if (autoLogin)
+        {
+            var update = new LogicUpdate(3f);
+            update.Start(OnAutoLoginUpdate);
+        }
+    }
+
+    private void OnAutoLoginUpdate()
+    {
+        if (StageLoad.Instance.currentStage is LoginStage)
+        {
+            var loginWin = WindowCenter.Instance.Get<LoginWin>();
+            if (loginWin != null)
+            {
+                var accountIpf = loginWin.transform.FindComponent("InputField", "Container_Account/AccountInput");
+                if (accountIpf != null)
+                {
+                    (accountIpf as InputField).text = StringUtility.Contact("Test_", UnityEngine.Random.Range(10000, 99999));
+                }
+
+                var enterGame = loginWin.transform.FindComponent("Button", "Container_EnterGame/LoginButton");
+                (enterGame as Button).onClick.Invoke();
+            }
+        }
+
+        if (StageLoad.Instance.currentStage is SelectRoleStage)
+        {
+            var win = WindowCenter.Instance.Get<SelectRoleWin>();
+            if (win != null)
+            {
+                var enterGame = win.transform.FindComponent("Button", "Container_Right/Btn_EnterGame");
+                if (enterGame is Button)
+                {
+                    (enterGame as Button).onClick.Invoke();
+                }
+            }
+        }
+
+        if (StageLoad.Instance.currentStage is CreateRoleStage)
+        {
+            var win = WindowCenter.Instance.Get<CreateRoleWin>();
+            if (win != null)
+            {
+                var enterGame = win.transform.FindComponent("Button", "Container_Right/Btn_CreateRole");
+                if (enterGame is Button)
+                {
+                    (enterGame as Button).onClick.Invoke();
+                }
+            }
+        }
     }
 
     public void CreateDebugRoot()

--
Gitblit v1.8.0