Skip to content

Commit 037eee0

Browse files
committed
加入调试器模块
加入调试器模块
1 parent 274b727 commit 037eee0

File tree

12 files changed

+699
-12
lines changed

12 files changed

+699
-12
lines changed

Assets/Game/Prefab/GameMode.prefab

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ MonoBehaviour:
5151
m_Script: {fileID: 11500000, guid: 274626dace099bf4597fe6bc0ea258e9, type: 3}
5252
m_Name:
5353
m_EditorClassIdentifier:
54-
IsEditorMode: 1
55-
DefaultPathType: 0
56-
AssetBundleName: AssetBundles/AssetBundles
54+
ResUpdateType: 2
55+
LocalPathType: 0
56+
ResUpdatePath:
57+
DebugEnable: 1

Assets/Game/Scene/Main.unity

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ RenderSettings:
3838
m_ReflectionIntensity: 1
3939
m_CustomReflection: {fileID: 0}
4040
m_Sun: {fileID: 0}
41-
m_IndirectSpecularColor: {r: 0.44657844, g: 0.49641222, b: 0.57481694, a: 1}
41+
m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1}
4242
m_UseRadianceAmbientProbe: 0
4343
--- !u!157 &3
4444
LightmapSettings:

Assets/Game/Scripts/Base/GameMode.cs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public class GameMode : MonoBehaviour
2525
public static AudioManager Audio;
2626
public static LocalizationManager Localization;
2727
public static SettingManager Setting;
28+
public static DebugManager Debug;
2829

2930
/// <summary>
3031
/// 当前程序集
@@ -49,12 +50,15 @@ public class GameMode : MonoBehaviour
4950
/// 资源更新的路径
5051
/// </summary>
5152
public string ResUpdatePath = "";
52-
#endregion
53-
54-
#endregion
53+
/// <summary>
54+
/// 是否开启调试器
55+
/// </summary>
56+
public bool DebugEnable = true;
57+
#endregion
5558

59+
#endregion
5660

57-
IEnumerator Start()
61+
IEnumerator Start()
5862
{
5963
//默认不销毁
6064
DontDestroyOnLoad(gameObject);
@@ -69,6 +73,7 @@ IEnumerator Start()
6973
Audio = GameFrameworkMode.GetModule<AudioManager>();
7074
Localization = GameFrameworkMode.GetModule<LocalizationManager>();
7175
Setting = GameFrameworkMode.GetModule<SettingManager>();
76+
Debug = GameFrameworkMode.GetModule<DebugManager>();
7277
#endregion
7378

7479
#region resource
@@ -108,9 +113,15 @@ IEnumerator Start()
108113
yield return new WaitForEndOfFrame();
109114
State.SetStateStart();
110115
#endregion
111-
}
112-
113116

117+
#region Debug
118+
GameObject debugHelper = new GameObject("DebugHelper");
119+
debugHelper.transform.SetParent(transform);
120+
Debug.SetDebugHelper(debugHelper.AddComponent<DebugHelper>());
121+
Debug.Enable = DebugEnable;
122+
#endregion
123+
}
124+
114125
private void Update()
115126
{
116127
GameFrameworkMode.Update();
@@ -125,6 +136,5 @@ private void OnDestroy()
125136
{
126137
GameFrameworkMode.ShutDown();
127138
}
128-
129139
}
130140
}

Assets/Game/Scripts/Editor/GameModeEditor.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class GameModeEditor : Editor
2727
private bool _dataTableModule = true;
2828
private bool _nodeDataModule = true;
2929
private bool _stepModule = true;
30+
private bool _debugModule = true;
3031

3132
////Color.cyan;
3233
private Color _defaultColor;
@@ -49,6 +50,9 @@ public class GameModeEditor : Editor
4950
//步骤模块的颜色
5051
private Color _stepColor = new Color(0.439f, 0.631f, 0.624f, 1.0f);
5152

53+
//调试模块的颜色
54+
private Color _debugColor = new Color(1f, 0.100f, 0.888f, 1.0f);
55+
5256
//所有状态
5357
private List<string> _listState;
5458

@@ -210,6 +214,23 @@ public override void OnInspectorGUI()
210214

211215
#endregion
212216

217+
#region 调试模块
218+
219+
GUI.color = _debugColor;
220+
GUILayout.BeginVertical("Box");
221+
GUI.color = _defaultColor;
222+
GUILayout.BeginHorizontal();
223+
GUILayout.Space(12);
224+
_debugModule = EditorGUILayout.Foldout(_debugModule, "Debug Module", true);
225+
if (EditorApplication.isPlaying)
226+
_debugModule = !EditorApplication.isPlaying;
227+
GUILayout.EndHorizontal();
228+
if (_debugModule)
229+
DrawDebugGUI();
230+
GUILayout.EndVertical();
231+
232+
#endregion
233+
213234
GUILayout.EndVertical();
214235

215236
//保存设置
@@ -435,5 +456,17 @@ void DrawStepGUI()
435456

436457
//GUILayout.EndVertical();
437458
}
459+
460+
//绘制调试界面
461+
void DrawDebugGUI()
462+
{
463+
GUILayout.BeginVertical("HelpBox");
464+
465+
GUI.color = _gameMode.DebugEnable ? Color.white : Color.gray;
466+
_gameMode.DebugEnable = GUILayout.Toggle(_gameMode.DebugEnable, "Enable");
467+
GUI.color = Color.white;
468+
469+
GUILayout.EndVertical();
470+
}
438471
}
439472
}

Assets/GameFramework/Debug.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)