2025-02-22 17:25:54 +08:00
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
|
using UnityEditor;
|
2025-02-24 17:59:44 +08:00
|
|
|
|
using UnityEditor.Compilation;
|
2025-02-22 17:25:54 +08:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace DCFApixels.DebugXCore.Internal
|
|
|
|
|
{
|
|
|
|
|
internal class DebugXSettings : EditorWindow
|
|
|
|
|
{
|
|
|
|
|
[MenuItem("Tools/DebugX/Settings")]
|
|
|
|
|
private static void Open()
|
|
|
|
|
{
|
|
|
|
|
DebugXSettings window = (DebugXSettings)EditorWindow.GetWindow(typeof(DebugXSettings));
|
|
|
|
|
window.Show();
|
2025-03-12 22:33:58 +08:00
|
|
|
|
//window._isHasDisableDebugXInBuildSymbols = null;
|
2025-02-24 17:59:44 +08:00
|
|
|
|
CompilationPipeline.compilationFinished -= CompilationPipeline_compilationFinished;
|
|
|
|
|
CompilationPipeline.compilationFinished += CompilationPipeline_compilationFinished;
|
2025-02-22 17:25:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
2025-02-24 17:59:44 +08:00
|
|
|
|
private static void CompilationPipeline_compilationFinished(object obj)
|
|
|
|
|
{
|
2025-03-12 22:33:58 +08:00
|
|
|
|
//_isCompilation = false;
|
|
|
|
|
_defines = null;
|
2025-02-24 17:59:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
2025-03-12 22:33:58 +08:00
|
|
|
|
//private static bool _isCompilation;
|
|
|
|
|
//private bool? _isHasDisableDebugXInBuildSymbols = false;
|
|
|
|
|
//private const string DEFINE_NAME = nameof(DebugXDefines.DEBUGX_DISABLE_INBUILD);
|
|
|
|
|
private static (string name, bool flag)[] _defines = null;
|
2025-04-08 17:58:34 +08:00
|
|
|
|
private static Vector2 _pos;
|
|
|
|
|
|
2025-02-22 17:25:54 +08:00
|
|
|
|
private void OnGUI()
|
|
|
|
|
{
|
2025-04-08 17:58:34 +08:00
|
|
|
|
_pos = GUILayout.BeginScrollView(_pos, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
|
2025-02-22 17:25:54 +08:00
|
|
|
|
float tmpValue;
|
|
|
|
|
|
|
|
|
|
DebugX.GlobalTimeScale = EditorGUILayout.FloatField("TimeScale", DebugX.GlobalTimeScale);
|
|
|
|
|
EditorGUI.BeginChangeCheck();
|
|
|
|
|
tmpValue = EditorGUILayout.Slider(DebugX.GlobalTimeScale, 0, 2);
|
|
|
|
|
if (EditorGUI.EndChangeCheck())
|
|
|
|
|
{
|
|
|
|
|
DebugX.GlobalTimeScale = tmpValue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DebugX.GlobalDotSize = EditorGUILayout.FloatField("DotSize", DebugX.GlobalDotSize);
|
|
|
|
|
EditorGUI.BeginChangeCheck();
|
|
|
|
|
tmpValue = EditorGUILayout.Slider(DebugX.GlobalDotSize, 0, 2);
|
|
|
|
|
if (EditorGUI.EndChangeCheck())
|
|
|
|
|
{
|
|
|
|
|
DebugX.GlobalDotSize = tmpValue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DebugX.GlobalColor = EditorGUILayout.ColorField("Color", DebugX.GlobalColor);
|
|
|
|
|
Color color = DebugX.GlobalColor;
|
|
|
|
|
color.a = EditorGUILayout.Slider(DebugX.GlobalColor.a, 0, 1);
|
|
|
|
|
DebugX.GlobalColor = color;
|
|
|
|
|
|
2025-07-23 21:23:54 +08:00
|
|
|
|
|
|
|
|
|
DebugX.GlobalGreaterPassAlpha = EditorGUILayout.FloatField("GreaterPassAlpha", DebugX.GlobalGreaterPassAlpha);
|
|
|
|
|
EditorGUI.BeginChangeCheck();
|
|
|
|
|
tmpValue = EditorGUILayout.Slider(DebugX.GlobalGreaterPassAlpha, 0, 2);
|
|
|
|
|
if (EditorGUI.EndChangeCheck())
|
|
|
|
|
{
|
|
|
|
|
DebugX.GlobalGreaterPassAlpha = tmpValue;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-08 17:58:34 +08:00
|
|
|
|
if (GUILayout.Button("Reset"))
|
|
|
|
|
{
|
|
|
|
|
DebugX.ResetGlobals();
|
|
|
|
|
}
|
|
|
|
|
if (GUILayout.Button("Clear All Gizmos"))
|
|
|
|
|
{
|
|
|
|
|
DebugX.ClearAllGizmos();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GUILayout.Space(4);
|
|
|
|
|
|
|
|
|
|
GUILayout.BeginVertical(EditorStyles.helpBox);
|
|
|
|
|
GUILayout.Label("Information", EditorStyles.helpBox);
|
|
|
|
|
DrawReadonlyLeftToggle("Is SRP", DebugXConsts.IsSRP);
|
|
|
|
|
DrawReadonlyLeftToggle("Support GPU Instancing", DebugXConsts.IsSupportsComputeShaders);
|
|
|
|
|
DrawReadonlyLeftToggle("Support OnGizmosDraw methods", DebugXConsts.IsSRP);
|
|
|
|
|
GUILayout.EndVertical();
|
2025-02-24 17:59:44 +08:00
|
|
|
|
|
2025-03-12 22:33:58 +08:00
|
|
|
|
GUILayout.BeginVertical(EditorStyles.helpBox);
|
|
|
|
|
GUILayout.Label("Scripting Define Symbols", EditorStyles.helpBox);
|
|
|
|
|
if (_defines == null)
|
2025-02-24 17:59:44 +08:00
|
|
|
|
{
|
2025-03-12 22:33:58 +08:00
|
|
|
|
_defines = DefinesUtility.LoadDefines(typeof(DebugXDefines));
|
|
|
|
|
}
|
|
|
|
|
for (int i = 0; i < _defines.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
ref var define = ref _defines[i];
|
|
|
|
|
define.flag = EditorGUILayout.ToggleLeft(define.name, define.flag);
|
2025-02-24 17:59:44 +08:00
|
|
|
|
}
|
2025-03-12 22:33:58 +08:00
|
|
|
|
if (GUILayout.Button("Apply Defines"))
|
2025-02-24 17:59:44 +08:00
|
|
|
|
{
|
2025-03-12 22:33:58 +08:00
|
|
|
|
DefinesUtility.ApplyDefines(_defines);
|
2025-02-24 17:59:44 +08:00
|
|
|
|
}
|
2025-03-12 22:33:58 +08:00
|
|
|
|
GUILayout.EndVertical();
|
|
|
|
|
|
2025-04-08 17:58:34 +08:00
|
|
|
|
GUILayout.EndScrollView();
|
|
|
|
|
}
|
2025-02-22 17:25:54 +08:00
|
|
|
|
|
2025-04-08 17:58:34 +08:00
|
|
|
|
private void DrawReadonlyLeftToggle(string text, bool value)
|
|
|
|
|
{
|
|
|
|
|
GUILayout.BeginHorizontal();
|
|
|
|
|
bool GUI_enabled_default = GUI.enabled;
|
|
|
|
|
GUI.enabled = false;
|
|
|
|
|
EditorGUILayout.Toggle(value, GUILayout.Width(14), GUILayout.ExpandWidth(false));
|
|
|
|
|
GUI.enabled = GUI_enabled_default;
|
|
|
|
|
EditorGUILayout.LabelField(text, GUILayout.ExpandWidth(true));
|
|
|
|
|
GUILayout.EndHorizontal();
|
2025-02-22 17:25:54 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|