mirror of
https://github.com/DCFApixels/Unity-DebugX.git
synced 2025-09-18 01:54:37 +08:00
143 lines
5.8 KiB
C#
143 lines
5.8 KiB
C#
#if UNITY_EDITOR
|
|
using UnityEditor;
|
|
using UnityEditor.Compilation;
|
|
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();
|
|
//window._isHasDisableDebugXInBuildSymbols = null;
|
|
CompilationPipeline.compilationFinished -= CompilationPipeline_compilationFinished;
|
|
CompilationPipeline.compilationFinished += CompilationPipeline_compilationFinished;
|
|
}
|
|
|
|
private static void CompilationPipeline_compilationFinished(object obj)
|
|
{
|
|
//_isCompilation = false;
|
|
_defines = null;
|
|
}
|
|
|
|
//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;
|
|
private void OnGUI()
|
|
{
|
|
|
|
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;
|
|
|
|
|
|
GUILayout.BeginVertical(EditorStyles.helpBox);
|
|
GUILayout.Label("Scripting Define Symbols", EditorStyles.helpBox);
|
|
if (_defines == null)
|
|
{
|
|
_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);
|
|
}
|
|
if (GUILayout.Button("Apply Defines"))
|
|
{
|
|
DefinesUtility.ApplyDefines(_defines);
|
|
}
|
|
GUILayout.EndVertical();
|
|
|
|
// if (_isCompilation == false)
|
|
// {
|
|
// if (_isHasDisableDebugXInBuildSymbols == null)
|
|
// {
|
|
// BuildTargetGroup group = EditorUserBuildSettings.selectedBuildTargetGroup;
|
|
//#if UNITY_6000_0_OR_NEWER
|
|
// string symbolsString = PlayerSettings.GetScriptingDefineSymbols(NamedBuildTarget.FromBuildTargetGroup(group));
|
|
//#else
|
|
// string symbolsString = PlayerSettings.GetScriptingDefineSymbolsForGroup(group);
|
|
//#endif
|
|
// _isHasDisableDebugXInBuildSymbols = symbolsString.Contains(DEFINE_NAME);
|
|
// }
|
|
//
|
|
// EditorGUI.BeginChangeCheck();
|
|
// _isHasDisableDebugXInBuildSymbols = !EditorGUILayout.ToggleLeft("Show Gizmos in Build", !_isHasDisableDebugXInBuildSymbols.Value);
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
// if (EditorGUI.EndChangeCheck())
|
|
// {
|
|
// BuildTargetGroup group = EditorUserBuildSettings.selectedBuildTargetGroup;
|
|
//#if UNITY_6000_0_OR_NEWER
|
|
// string symbolsString = PlayerSettings.GetScriptingDefineSymbols(NamedBuildTarget.FromBuildTargetGroup(group));
|
|
//#else
|
|
// string symbolsString = PlayerSettings.GetScriptingDefineSymbolsForGroup(group);
|
|
//#endif
|
|
// if (symbolsString.Contains(DEFINE_NAME) == false)
|
|
// {
|
|
// symbolsString = symbolsString + ", " + DEFINE_NAME;
|
|
// }
|
|
// else
|
|
// {
|
|
// symbolsString = symbolsString.Replace(DEFINE_NAME, "");
|
|
//
|
|
// }
|
|
//
|
|
//#if UNITY_6000_0_OR_NEWER
|
|
// PlayerSettings.SetScriptingDefineSymbols(NamedBuildTarget.FromBuildTargetGroup(group), symbolsString);
|
|
//#else
|
|
// PlayerSettings.SetScriptingDefineSymbolsForGroup(group, symbolsString);
|
|
//#endif
|
|
// _isCompilation = true;
|
|
// }
|
|
// }
|
|
// else
|
|
// {
|
|
// _isHasDisableDebugXInBuildSymbols = null;
|
|
// GUI.enabled = false;
|
|
// EditorGUILayout.ToggleLeft("Show Gizmos in Build (Locked for compilation)", false);
|
|
// GUI.enabled = true;
|
|
// }
|
|
|
|
|
|
|
|
|
|
if (GUILayout.Button("Reset"))
|
|
{
|
|
DebugX.ResetGlobals();
|
|
}
|
|
|
|
if (GUILayout.Button("Clear All Gizmos"))
|
|
{
|
|
DebugX.ClearAllGizmos();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endif |