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;
|
}
|
|
}
|