| | |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using Snxxz.UI; |
| | | using LitJson; |
| | | |
| | | public class DebugUtility : Singleton<DebugUtility> |
| | | { |
| | | const string url = "http://pub.game.secondworld.net.cn:11000/dbg_player/?"; |
| | | |
| | | GameObject debugRoot; |
| | | |
| | | bool m_DebugAccount = false; |
| | | public bool debugAccount { |
| | | get { return m_DebugAccount; } |
| | | private set { |
| | | if (m_DebugAccount != value) |
| | | { |
| | | m_DebugAccount = value; |
| | | if (debugAccount) |
| | | { |
| | | RunTimeExceptionUtility.Instance.Init(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void Init() |
| | | { |
| | | if (VersionConfig.Get().debugVersion) |
| | | { |
| | | debugAccount = true; |
| | | } |
| | | else |
| | | { |
| | | debugAccount = false; |
| | | } |
| | | } |
| | | |
| | | public void CreateDebugRoot() |
| | | { |
| | | if (debugRoot == null) |
| | | { |
| | | var prefab = Resources.Load<GameObject>("UI/Prefabs/UIRootDebug"); |
| | | debugRoot = GameObject.Instantiate(prefab); |
| | | MonoBehaviour.DontDestroyOnLoad(debugRoot); |
| | | debugRoot.name = "UIRootDebug"; |
| | | } |
| | | } |
| | | |
| | | public void RequestDebugAuthority(string _account) |
| | | { |
| | | debugAccount = false; |
| | | var tables = new Dictionary<string, string>(); |
| | | tables["channel"] = VersionConfig.Get().appId; |
| | | tables["player"] = ModelCenter.Instance.GetModel<LoginModel>().sdkLoginResult.account; |
| | | |
| | | 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); |
| | | debugAccount = debugAuthority.dbg == 1; |
| | | } |
| | | } |
| | | |
| | | struct DebugAuthority |
| | | { |
| | | public int dbg; |
| | | } |
| | | |
| | | } |
| | | using System.Collections;
|
| | | using System.Collections.Generic;
|
| | | using UnityEngine;
|
| | | using Snxxz.UI;
|
| | | using LitJson;
|
| | | using System.IO;
|
| | |
|
| | | public class DebugUtility : Singleton<DebugUtility>
|
| | | {
|
| | | const string url = "http://pub.game.2460web.com:11000/dbg_player/?";
|
| | |
|
| | | GameObject debugRoot;
|
| | |
|
| | | bool m_DebugAccount = false;
|
| | | public bool debugAccount
|
| | | {
|
| | | get { return m_DebugAccount; }
|
| | | private set
|
| | | {
|
| | | if (m_DebugAccount != value)
|
| | | {
|
| | | m_DebugAccount = value;
|
| | | if (debugAccount)
|
| | | {
|
| | | RunTimeExceptionUtility.Instance.Init();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | public int debugBranch = -1;
|
| | |
|
| | | public void Init()
|
| | | {
|
| | | if (VersionConfig.Get().debugVersion)
|
| | | {
|
| | | debugAccount = true;
|
| | | }
|
| | | else
|
| | | {
|
| | | var parentDirectory = Directory.GetParent(Application.persistentDataPath);
|
| | | debugAccount = File.Exists(parentDirectory + "/Debug");
|
| | |
|
| | | if (debugAccount)
|
| | | {
|
| | | var content = File.ReadAllText(parentDirectory + "/Debug");
|
| | | if (!string.IsNullOrEmpty(content))
|
| | | {
|
| | | var json = JsonMapper.ToObject<DebugBranch>(File.ReadAllText(parentDirectory + "/Debug"));
|
| | | debugBranch = json.branch;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | if (debugAccount)
|
| | | {
|
| | | DebugEx.EnableLog = LocalSave.GetBool("DesignEnableLog", true);
|
| | | DebugEx.EnableLogWarning = LocalSave.GetBool("DesignEnableLogWarning", true);
|
| | | DebugEx.EnableLogError = LocalSave.GetBool("DesignEnableLogError", true);
|
| | | DebugEx.EnableNetLog = false;
|
| | | }
|
| | | else
|
| | | {
|
| | | DebugEx.EnableLog = false;
|
| | | DebugEx.EnableLogWarning = false;
|
| | | DebugEx.EnableLogError = false;
|
| | | DebugEx.EnableNetLog = false;
|
| | | }
|
| | | }
|
| | |
|
| | | public void CreateDebugRoot()
|
| | | {
|
| | | if (debugRoot == null)
|
| | | {
|
| | | var prefab = Resources.Load<GameObject>("UI/Prefabs/UIRootDebug");
|
| | | debugRoot = GameObject.Instantiate(prefab);
|
| | | MonoBehaviour.DontDestroyOnLoad(debugRoot);
|
| | | debugRoot.name = "UIRootDebug";
|
| | | }
|
| | | }
|
| | |
|
| | | public void RequestDebugAuthority(string _account)
|
| | | {
|
| | | debugAccount = false;
|
| | | var tables = new Dictionary<string, string>();
|
| | | tables["channel"] = VersionConfig.Get().appId;
|
| | | tables["player"] = ModelCenter.Instance.GetModel<LoginModel>().sdkLoginResult.account;
|
| | |
|
| | | 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);
|
| | | debugAccount = debugAuthority.dbg == 1;
|
| | | }
|
| | | }
|
| | |
|
| | | public static void SetLogAble(bool _able)
|
| | | {
|
| | | LocalSave.SetBool("DesignEnableLog", _able);
|
| | | DebugEx.EnableLog = _able;
|
| | | }
|
| | |
|
| | | public static void SetLogWarningAble(bool _able)
|
| | | {
|
| | | LocalSave.SetBool("DesignEnableLogWarning", _able);
|
| | | DebugEx.EnableLogWarning = _able;
|
| | | }
|
| | |
|
| | | public static void SetLogErrorAble(bool _able)
|
| | | {
|
| | | LocalSave.SetBool("DesignEnableLogError", _able);
|
| | | DebugEx.EnableLogError = _able;
|
| | | }
|
| | |
|
| | | public static void SetLogNetAble(bool _able)
|
| | | {
|
| | | DebugEx.EnableNetLog = _able;
|
| | | }
|
| | |
|
| | | struct DebugAuthority
|
| | | {
|
| | | public int dbg;
|
| | | }
|
| | |
|
| | | public class DebugBranch
|
| | | {
|
| | | public int branch = -1;
|
| | | }
|
| | |
|
| | | }
|