1.重名所有App级模块为Service 2.移除Module中心 移除SingletonManager 3.引入Service Scope Context概念 避免上下文Manager到处引用 4.修复部分bug
220 lines
9.6 KiB
C#
220 lines
9.6 KiB
C#
using UnityEngine;
|
|
|
|
|
|
namespace AlicizaX.Debugger.Runtime
|
|
{
|
|
public sealed partial class DebuggerComponent
|
|
{
|
|
private sealed class SettingsWindow : ScrollableDebuggerWindowBase
|
|
{
|
|
private DebuggerComponent _mDebuggerComponent = null;
|
|
private float m_LastIconX = 0f;
|
|
private float m_LastIconY = 0f;
|
|
private float m_LastWindowX = 0f;
|
|
private float m_LastWindowY = 0f;
|
|
private float m_LastWindowWidth = 0f;
|
|
private float m_LastWindowHeight = 0f;
|
|
private float m_LastWindowScale = 0f;
|
|
|
|
public override void Initialize(params object[] args)
|
|
{
|
|
_mDebuggerComponent = DebuggerComponent.Instance;
|
|
if (_mDebuggerComponent == null)
|
|
{
|
|
Log.Error("Debugger component is invalid.");
|
|
return;
|
|
}
|
|
|
|
|
|
m_LastIconX = Utility.PlayerPrefsX.GetFloat("Debugger.Icon.X", DefaultIconRect.x);
|
|
m_LastIconY = Utility.PlayerPrefsX.GetFloat("Debugger.Icon.Y", DefaultIconRect.y);
|
|
m_LastWindowX = Utility.PlayerPrefsX.GetFloat("Debugger.Window.X", DefaultWindowRect.x);
|
|
m_LastWindowY = Utility.PlayerPrefsX.GetFloat("Debugger.Window.Y", DefaultWindowRect.y);
|
|
m_LastWindowWidth = Utility.PlayerPrefsX.GetFloat("Debugger.Window.Width", DefaultWindowRect.width);
|
|
m_LastWindowHeight = Utility.PlayerPrefsX.GetFloat("Debugger.Window.Height", DefaultWindowRect.height);
|
|
_mDebuggerComponent.WindowScale = m_LastWindowScale = Utility.PlayerPrefsX.GetFloat("Debugger.Window.Scale", DefaultWindowScale);
|
|
_mDebuggerComponent.IconRect = new Rect(m_LastIconX, m_LastIconY, DefaultIconRect.width, DefaultIconRect.height);
|
|
_mDebuggerComponent.WindowRect = new Rect(m_LastWindowX, m_LastWindowY, m_LastWindowWidth, m_LastWindowHeight);
|
|
}
|
|
|
|
public override void OnUpdate(float elapseSeconds, float realElapseSeconds)
|
|
{
|
|
if (m_LastIconX != _mDebuggerComponent.IconRect.x)
|
|
{
|
|
m_LastIconX = _mDebuggerComponent.IconRect.x;
|
|
Utility.PlayerPrefsX.SetFloat("Debugger.Icon.X", _mDebuggerComponent.IconRect.x);
|
|
}
|
|
|
|
if (m_LastIconY != _mDebuggerComponent.IconRect.y)
|
|
{
|
|
m_LastIconY = _mDebuggerComponent.IconRect.y;
|
|
Utility.PlayerPrefsX.SetFloat("Debugger.Icon.Y", _mDebuggerComponent.IconRect.y);
|
|
}
|
|
|
|
if (m_LastWindowX != _mDebuggerComponent.WindowRect.x)
|
|
{
|
|
m_LastWindowX = _mDebuggerComponent.WindowRect.x;
|
|
Utility.PlayerPrefsX.SetFloat("Debugger.Window.X", _mDebuggerComponent.WindowRect.x);
|
|
}
|
|
|
|
if (m_LastWindowY != _mDebuggerComponent.WindowRect.y)
|
|
{
|
|
m_LastWindowY = _mDebuggerComponent.WindowRect.y;
|
|
Utility.PlayerPrefsX.SetFloat("Debugger.Window.Y", _mDebuggerComponent.WindowRect.y);
|
|
}
|
|
|
|
if (m_LastWindowWidth != _mDebuggerComponent.WindowRect.width)
|
|
{
|
|
m_LastWindowWidth = _mDebuggerComponent.WindowRect.width;
|
|
Utility.PlayerPrefsX.SetFloat("Debugger.Window.Width", _mDebuggerComponent.WindowRect.width);
|
|
}
|
|
|
|
if (m_LastWindowHeight != _mDebuggerComponent.WindowRect.height)
|
|
{
|
|
m_LastWindowHeight = _mDebuggerComponent.WindowRect.height;
|
|
Utility.PlayerPrefsX.SetFloat("Debugger.Window.Height", _mDebuggerComponent.WindowRect.height);
|
|
}
|
|
|
|
if (m_LastWindowScale != _mDebuggerComponent.WindowScale)
|
|
{
|
|
m_LastWindowScale = _mDebuggerComponent.WindowScale;
|
|
Utility.PlayerPrefsX.SetFloat("Debugger.Window.Scale", _mDebuggerComponent.WindowScale);
|
|
}
|
|
}
|
|
|
|
protected override void OnDrawScrollableWindow()
|
|
{
|
|
GUILayout.Label("<b>Window Settings</b>");
|
|
GUILayout.BeginVertical("box");
|
|
{
|
|
GUILayout.BeginHorizontal();
|
|
{
|
|
GUILayout.Label("Position:", GUILayout.Width(60f));
|
|
GUILayout.Label("Drag window caption to move position.");
|
|
}
|
|
GUILayout.EndHorizontal();
|
|
|
|
GUILayout.BeginHorizontal();
|
|
{
|
|
float width = _mDebuggerComponent.WindowRect.width;
|
|
GUILayout.Label("Width:", GUILayout.Width(60f));
|
|
if (GUILayout.RepeatButton("-", GUILayout.Width(30f)))
|
|
{
|
|
width--;
|
|
}
|
|
|
|
width = GUILayout.HorizontalSlider(width, 100f, Screen.width - 20f);
|
|
if (GUILayout.RepeatButton("+", GUILayout.Width(30f)))
|
|
{
|
|
width++;
|
|
}
|
|
|
|
width = Mathf.Clamp(width, 100f, Screen.width - 20f);
|
|
if (width != _mDebuggerComponent.WindowRect.width)
|
|
{
|
|
_mDebuggerComponent.WindowRect = new Rect(_mDebuggerComponent.WindowRect.x, _mDebuggerComponent.WindowRect.y, width, _mDebuggerComponent.WindowRect.height);
|
|
}
|
|
}
|
|
GUILayout.EndHorizontal();
|
|
|
|
GUILayout.BeginHorizontal();
|
|
{
|
|
float height = _mDebuggerComponent.WindowRect.height;
|
|
GUILayout.Label("Height:", GUILayout.Width(60f));
|
|
if (GUILayout.RepeatButton("-", GUILayout.Width(30f)))
|
|
{
|
|
height--;
|
|
}
|
|
|
|
height = GUILayout.HorizontalSlider(height, 100f, Screen.height - 20f);
|
|
if (GUILayout.RepeatButton("+", GUILayout.Width(30f)))
|
|
{
|
|
height++;
|
|
}
|
|
|
|
height = Mathf.Clamp(height, 100f, Screen.height - 20f);
|
|
if (height != _mDebuggerComponent.WindowRect.height)
|
|
{
|
|
_mDebuggerComponent.WindowRect = new Rect(_mDebuggerComponent.WindowRect.x, _mDebuggerComponent.WindowRect.y, _mDebuggerComponent.WindowRect.width, height);
|
|
}
|
|
}
|
|
GUILayout.EndHorizontal();
|
|
|
|
GUILayout.BeginHorizontal();
|
|
{
|
|
float scale = _mDebuggerComponent.WindowScale;
|
|
GUILayout.Label("Scale:", GUILayout.Width(60f));
|
|
if (GUILayout.RepeatButton("-", GUILayout.Width(30f)))
|
|
{
|
|
scale -= 0.01f;
|
|
}
|
|
|
|
scale = GUILayout.HorizontalSlider(scale, 0.5f, 4f);
|
|
if (GUILayout.RepeatButton("+", GUILayout.Width(30f)))
|
|
{
|
|
scale += 0.01f;
|
|
}
|
|
|
|
scale = Mathf.Clamp(scale, 0.5f, 4f);
|
|
if (scale != _mDebuggerComponent.WindowScale)
|
|
{
|
|
_mDebuggerComponent.WindowScale = scale;
|
|
}
|
|
}
|
|
GUILayout.EndHorizontal();
|
|
|
|
GUILayout.BeginHorizontal();
|
|
{
|
|
if (GUILayout.Button("0.5x", GUILayout.Height(60f)))
|
|
{
|
|
_mDebuggerComponent.WindowScale = 0.5f;
|
|
}
|
|
|
|
if (GUILayout.Button("1.0x", GUILayout.Height(60f)))
|
|
{
|
|
_mDebuggerComponent.WindowScale = 1f;
|
|
}
|
|
|
|
if (GUILayout.Button("1.5x", GUILayout.Height(60f)))
|
|
{
|
|
_mDebuggerComponent.WindowScale = 1.5f;
|
|
}
|
|
|
|
if (GUILayout.Button("2.0x", GUILayout.Height(60f)))
|
|
{
|
|
_mDebuggerComponent.WindowScale = 2f;
|
|
}
|
|
|
|
if (GUILayout.Button("2.5x", GUILayout.Height(60f)))
|
|
{
|
|
_mDebuggerComponent.WindowScale = 2.5f;
|
|
}
|
|
|
|
if (GUILayout.Button("3.0x", GUILayout.Height(60f)))
|
|
{
|
|
_mDebuggerComponent.WindowScale = 3f;
|
|
}
|
|
|
|
if (GUILayout.Button("3.5x", GUILayout.Height(60f)))
|
|
{
|
|
_mDebuggerComponent.WindowScale = 3.5f;
|
|
}
|
|
|
|
if (GUILayout.Button("4.0x", GUILayout.Height(60f)))
|
|
{
|
|
_mDebuggerComponent.WindowScale = 4f;
|
|
}
|
|
}
|
|
GUILayout.EndHorizontal();
|
|
|
|
if (GUILayout.Button("Reset Layout", GUILayout.Height(30f)))
|
|
{
|
|
_mDebuggerComponent.ResetLayout();
|
|
}
|
|
}
|
|
GUILayout.EndVertical();
|
|
}
|
|
}
|
|
}
|
|
}
|