update: fix Debugger issue

deeplink
胡宇飞 2024-04-15 13:36:14 +08:00
parent cdf379be10
commit 54ef66a97d
2 changed files with 24 additions and 43 deletions

View File

@ -1,3 +1,5 @@
using System;
namespace Guru namespace Guru
{ {
using UnityEngine; using UnityEngine;
@ -5,6 +7,18 @@ namespace Guru
public partial class GuruSDK public partial class GuruSDK
{ {
private static bool _isDebuggerInited = false; private static bool _isDebuggerInited = false;
private static bool _useBaseOpions = true;
private static Debugger _debugger;
public static Debugger Debugger
{
get
{
if (_debugger == null) _debugger = Debugger.Instance;
return _debugger;
}
}
/// <summary> /// <summary>
/// 显示 Debugger /// 显示 Debugger
@ -17,10 +31,9 @@ namespace Guru
return false; return false;
} }
if (!_isDebuggerInited) if (_useBaseOpions)
{ {
InitDebuggerLayout(); InitDebuggerLayout();
_isDebuggerInited = true;
} }
Debugger.Show(); // 显示 Debugger 界面 Debugger.Show(); // 显示 Debugger 界面
@ -99,6 +112,11 @@ namespace Guru
return res; return res;
} }
public static Debugger.OptionLayout AddOption(string uri, string content = "", Action clickHandler = null)
{
return Debugger.AddOption(uri, content, clickHandler);
}
} }
} }

View File

@ -10,7 +10,7 @@ namespace Guru
using System.Linq; using System.Linq;
public class Debugger: IUpdater public class Debugger
{ {
public const string Version = "1.0.0"; public const string Version = "1.0.0";
private static bool _initOnce = false; private static bool _initOnce = false;
@ -64,8 +64,6 @@ namespace Guru
_initOnce = true; _initOnce = true;
_instance = new Debugger(); _instance = new Debugger();
_instance.StartService(); _instance.StartService();
// GuruSDK.RegisterUpdater(_instance);
} }
private void StartService() private void StartService()
@ -135,7 +133,8 @@ namespace Guru
public void ShowPage(string tabName = "") public void ShowPage(string tabName = "")
{ {
if (string.IsNullOrEmpty(tabName)) if (string.IsNullOrEmpty(tabName)
&& optionDicts != null && optionDicts.Count > 0)
{ {
tabName = optionDicts.Keys.First(); tabName = optionDicts.Keys.First();
} }
@ -175,7 +174,6 @@ namespace Guru
continue; continue;
} }
foreach (var item in ol.items) foreach (var item in ol.items)
{ {
switch (item.type) switch (item.type)
@ -191,9 +189,6 @@ namespace Guru
break; break;
} }
} }
} }
} }
else else
@ -275,38 +270,6 @@ namespace Guru
#endregion #endregion
#region API
private UpdaterState _state = UpdaterState.Prepare;
public UpdaterState State => _state;
public void Start()
{
_state = UpdaterState.Running;
}
public void OnUpdate()
{
if(Time.frameCount%5 == 0)
{
RenderPage(_curTabName);
}
}
public void Pause(bool paused)
{
_state = paused ? UpdaterState.Pause : UpdaterState.Running;
}
public void Kill()
{
_state = UpdaterState.Kill;
}
#endregion
} }