yyl
2025-06-13 eb1efcaa9be0e2340fc49b38dab8df18e36526c9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using LitJson;
using System.IO;
using UnityEngine.UI;
 
 
public class DebugUtility : Singleton<DebugUtility>
{
 
    GameObject debugRoot;
 
    bool m_DebugAccount = false;
    public bool debugAccount
    {
        get { return m_DebugAccount; }
        private set
        {
            if (m_DebugAccount != value)
            {
                m_DebugAccount = value;
                if (m_DebugAccount)
                {
                    RunTimeExceptionUtility.Instance.Init();
                }
            }
        }
    }
 
    public int debugBranch = -1;
 
    public bool isWhiteListAccount { get; set; }
 
    public bool autoLogin { get; private set; }
 
    public void Init()
    {
        isWhiteListAccount = false;
        if (VersionConfig.Get().debugVersion)
        {
            debugAccount = true;
        }
        else
        {
            var parentDirectory = Directory.GetParent(Application.persistentDataPath);
            debugAccount = File.Exists(parentDirectory + "/Debug");
        }
 
        if (LocalSave.GetString("#@#BrancH") != string.Empty)
        {
            var branch = LocalSave.GetString("#@#BrancH");
            int tmpbranch;
            int.TryParse(LocalSave.GetString("#@#BrancH").Substring(1), out tmpbranch);
            if (branch.StartsWith("d") && tmpbranch != 0)
            {
                debugBranch = tmpbranch;
                debugAccount = true;
            }
            else if (branch.StartsWith("r") && tmpbranch != 0)
            {
                debugBranch = tmpbranch;
                debugAccount = false;
            }
        }
 
        if (debugAccount)
        {
            if (Application.isMobilePlatform)
            {
                var parentDirectory = Directory.GetParent(Application.persistentDataPath);
                if (File.Exists(parentDirectory + "/Debug"))
                {
                    var content = File.ReadAllText(parentDirectory + "/Debug");
                    if (!string.IsNullOrEmpty(content))
                    {
                        var json = JsonMapper.ToObject<DebugBranch>(File.ReadAllText(parentDirectory + "/Debug"));
                        debugBranch = json.branch;
                    }
                }
            }
        }
 
 
 
 
        if (debugAccount)
        {
            Launch.Instance.EnableLog = LocalSave.GetBool("DesignEnableLog", true);
            Launch.Instance.EnableLogWarning = LocalSave.GetBool("DesignEnableLogWarning", true);
            Launch.Instance.EnableLogError = LocalSave.GetBool("DesignEnableLogError", true);
            Launch.Instance.EnableNetLog = false;
        }
        else
        {
            Launch.Instance.EnableLog = false;
            Launch.Instance.EnableLogWarning = false;
            Launch.Instance.EnableLogError = false;
            Launch.Instance.EnableNetLog = false;
        }
 
        autoLogin = Resources.Load<TextAsset>("AutoLogin") != null;
        if (autoLogin)
        {
            var update = new LogicUpdate(3f);
            update.Start(OnAutoLoginUpdate);
        }
    }
 
    private void OnAutoLoginUpdate()
    {
        // TODO YYL
        // if (StageLoad.Instance.currentStage is LoginStage)
        // {
            var loginWin = UIManager.Instance.GetUI<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 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()
    {
        if (debugRoot == null)
        {
            // var prefab = BuiltInLoader.LoadPrefab("UIRootDebug");
            // debugRoot = GameObject.Instantiate(prefab);
            // MonoBehaviour.DontDestroyOnLoad(debugRoot);
            // debugRoot.name = "UIRootDebug";
        }
    }
 
    public void RequestWhiteListAuthority(string _account)
    {
        //isWhiteListAccount = false;
        //var tables = new Dictionary<string, string>();
        //tables["channel"] = VersionConfig.Get().appId;
        //tables["player"] = ModelCenter.Instance.GetModel<LoginModel>().sdkLoginResult.account;
        //tables["game"] = VersionConfig.Get().gameId;
 
        //HttpRequest.Instance.RequestHttpGet(StringUtility.Contact(url, HttpRequest.HashtablaToString(tables)), HttpRequest.defaultHttpContentType, 1, OnDebugAuthority);
    }
 
    private void OnDebugAuthority(bool _ok, string _result)
    {
        if (_ok)
        {
            var debugAuthority = JsonMapper.ToObject<DebugAuthority>(_result);
            isWhiteListAccount = debugAuthority.dbg == 1;
        }
    }
 
    public static void SetLogAble(bool _able)
    {
        LocalSave.SetBool("DesignEnableLog", _able);
        Launch.Instance.EnableLog = _able;
    }
 
    public static void SetLogWarningAble(bool _able)
    {
        LocalSave.SetBool("DesignEnableLogWarning", _able);
        Launch.Instance.EnableLogWarning = _able;
    }
 
    public static void SetLogErrorAble(bool _able)
    {
        LocalSave.SetBool("DesignEnableLogError", _able);
        Launch.Instance.EnableLogError = _able;
    }
 
    public static void SetLogNetAble(bool _able)
    {
        Launch.Instance.EnableNetLog = _able;
    }
 
    struct DebugAuthority
    {
        public int dbg;
    }
 
    public class DebugBranch
    {
        public int branch = -1;
    }
 
}