Compare commits

..

No commits in common. "6f354f77e0315bc6856343845d3c6e6d0d157279" and "624379c950efd40d631d4797992dab53fa6c27cb" have entirely different histories.

11 changed files with 82 additions and 178 deletions

View File

@ -1,5 +1,6 @@
#if UNITY_EDITOR #if UNITY_EDITOR
using UnityEditor; using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Compilation; using UnityEditor.Compilation;
using UnityEngine; using UnityEngine;
@ -12,24 +13,22 @@ namespace DCFApixels.DebugXCore.Internal
{ {
DebugXSettings window = (DebugXSettings)EditorWindow.GetWindow(typeof(DebugXSettings)); DebugXSettings window = (DebugXSettings)EditorWindow.GetWindow(typeof(DebugXSettings));
window.Show(); window.Show();
//window._isHasDisableDebugXInBuildSymbols = null; window._isHasDisableDebugXInBuildSymbols = null;
CompilationPipeline.compilationFinished -= CompilationPipeline_compilationFinished; CompilationPipeline.compilationFinished -= CompilationPipeline_compilationFinished;
CompilationPipeline.compilationFinished += CompilationPipeline_compilationFinished; CompilationPipeline.compilationFinished += CompilationPipeline_compilationFinished;
} }
private static void CompilationPipeline_compilationFinished(object obj) private static void CompilationPipeline_compilationFinished(object obj)
{ {
//_isCompilation = false; _isCompilation = false;
_defines = null;
} }
//private static bool _isCompilation; private static bool _isCompilation;
//private bool? _isHasDisableDebugXInBuildSymbols = false; private bool? _isHasDisableDebugXInBuildSymbols = false;
//private const string DEFINE_NAME = nameof(DebugXDefines.DEBUGX_DISABLE_INBUILD); private const string DEFINE_NAME = nameof(DebugXDefines.DISABLE_DEBUGX_INBUILD);
private static (string name, bool flag)[] _defines = null;
private void OnGUI() private void OnGUI()
{ {
float tmpValue; float tmpValue;
DebugX.GlobalTimeScale = EditorGUILayout.FloatField("TimeScale", DebugX.GlobalTimeScale); DebugX.GlobalTimeScale = EditorGUILayout.FloatField("TimeScale", DebugX.GlobalTimeScale);
@ -54,76 +53,55 @@ namespace DCFApixels.DebugXCore.Internal
DebugX.GlobalColor = color; DebugX.GlobalColor = color;
GUILayout.BeginVertical(EditorStyles.helpBox); if (_isCompilation == false)
GUILayout.Label("Scripting Define Symbols", EditorStyles.helpBox);
if (_defines == null)
{ {
_defines = DefinesUtility.LoadDefines(typeof(DebugXDefines)); if (_isHasDisableDebugXInBuildSymbols == null)
} {
for (int i = 0; i < _defines.Length; i++) BuildTargetGroup group = EditorUserBuildSettings.selectedBuildTargetGroup;
{ #if UNITY_6000_0_OR_NEWER
ref var define = ref _defines[i]; string symbolsString = PlayerSettings.GetScriptingDefineSymbols(NamedBuildTarget.FromBuildTargetGroup(group));
define.flag = EditorGUILayout.ToggleLeft(define.name, define.flag); #else
} string symbolsString = PlayerSettings.GetScriptingDefineSymbolsForGroup(group);
if (GUILayout.Button("Apply Defines")) #endif
{ _isHasDisableDebugXInBuildSymbols = symbolsString.Contains(DEFINE_NAME);
DefinesUtility.ApplyDefines(_defines); }
}
GUILayout.EndVertical();
// if (_isCompilation == false) EditorGUI.BeginChangeCheck();
// { _isHasDisableDebugXInBuildSymbols = !EditorGUILayout.ToggleLeft("Show Gizmos in Build", !_isHasDisableDebugXInBuildSymbols.Value);
// if (_isHasDisableDebugXInBuildSymbols == null)
// { if (EditorGUI.EndChangeCheck())
// BuildTargetGroup group = EditorUserBuildSettings.selectedBuildTargetGroup; {
//#if UNITY_6000_0_OR_NEWER BuildTargetGroup group = EditorUserBuildSettings.selectedBuildTargetGroup;
// string symbolsString = PlayerSettings.GetScriptingDefineSymbols(NamedBuildTarget.FromBuildTargetGroup(group)); #if UNITY_6000_0_OR_NEWER
//#else string symbolsString = PlayerSettings.GetScriptingDefineSymbols(NamedBuildTarget.FromBuildTargetGroup(group));
// string symbolsString = PlayerSettings.GetScriptingDefineSymbolsForGroup(group); #else
//#endif string symbolsString = PlayerSettings.GetScriptingDefineSymbolsForGroup(group);
// _isHasDisableDebugXInBuildSymbols = symbolsString.Contains(DEFINE_NAME); #endif
// } if (symbolsString.Contains(DEFINE_NAME) == false)
// {
// EditorGUI.BeginChangeCheck(); symbolsString = symbolsString + ", " + DEFINE_NAME;
// _isHasDisableDebugXInBuildSymbols = !EditorGUILayout.ToggleLeft("Show Gizmos in Build", !_isHasDisableDebugXInBuildSymbols.Value); }
// else
// {
// symbolsString = symbolsString.Replace(DEFINE_NAME, "");
//
// }
// if (EditorGUI.EndChangeCheck())
// { #if UNITY_6000_0_OR_NEWER
// BuildTargetGroup group = EditorUserBuildSettings.selectedBuildTargetGroup; PlayerSettings.SetScriptingDefineSymbols(NamedBuildTarget.FromBuildTargetGroup(group), symbolsString);
//#if UNITY_6000_0_OR_NEWER #else
// string symbolsString = PlayerSettings.GetScriptingDefineSymbols(NamedBuildTarget.FromBuildTargetGroup(group)); PlayerSettings.SetScriptingDefineSymbolsForGroup(group, symbolsString);
//#else #endif
// string symbolsString = PlayerSettings.GetScriptingDefineSymbolsForGroup(group); _isCompilation = true;
//#endif }
// if (symbolsString.Contains(DEFINE_NAME) == false) }
// { else
// symbolsString = symbolsString + ", " + DEFINE_NAME; {
// } _isHasDisableDebugXInBuildSymbols = null;
// else GUI.enabled = false;
// { EditorGUILayout.ToggleLeft("Show Gizmos in Build (Locked for compilation)", false);
// symbolsString = symbolsString.Replace(DEFINE_NAME, ""); GUI.enabled = true;
// }
// }
//
//#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;
// }

View File

@ -1,40 +0,0 @@
using System;
using System.Linq;
using System.Reflection;
using UnityEditor;
using UnityEditor.Build;
namespace DCFApixels.DebugXCore.Internal
{
internal static class DefinesUtility
{
public static (string name, bool flag)[] LoadDefines(Type defineConstsType)
{
const BindingFlags REFL_FLAGS = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
var fields = defineConstsType.GetFields(REFL_FLAGS);
return fields.Where(o => o.FieldType == typeof(bool)).Select(o => (o.Name, (bool)o.GetValue(null))).ToArray();
}
public static void ApplyDefines((string name, bool flag)[] defines)
{
BuildTargetGroup group = EditorUserBuildSettings.selectedBuildTargetGroup;
#if UNITY_6000_0_OR_NEWER
string symbolsString = PlayerSettings.GetScriptingDefineSymbols(NamedBuildTarget.FromBuildTargetGroup(group));
#else
string symbolsString = PlayerSettings.GetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone);
#endif
for (int i = 0; i < defines.Length; i++)
{
symbolsString = symbolsString.Replace(defines[i].name, "");
}
symbolsString += ";" + string.Join(';', defines.Where(o => o.flag).Select(o => o.name));
#if UNITY_6000_0_OR_NEWER
PlayerSettings.SetScriptingDefineSymbols(NamedBuildTarget.FromBuildTargetGroup(group), symbolsString);
#else
PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone, symbolsString);
#endif
}
}
}

View File

@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 77addf06144f4214a925257238d65cb0

View File

@ -151,7 +151,7 @@ public struct SomeMesh : IStaticMesh
# Настройки # Настройки
Окно настроек "Tools -> DebugX -> Settings": Окно настроек "Tools -> DebugX -> Settings":
![image](https://github.com/user-attachments/assets/dee3954a-1c8a-442c-a4bb-d2c710e065a4) ![image](https://github.com/user-attachments/assets/7dd981c1-1e00-4b7d-9a73-376638094689)
<br> <br>
@ -253,7 +253,4 @@ SomeAssets assets = DebugXUtility.LoadStaticData(new SomeAssets(), "SomeAssets")
<br> <br>
# Define Symbols # Define Symbols
Все Define Symbols можно менять в окне настроек. + `DISABLE_DEBUGX_INBUILD` - по умолчанию Gizmo будут рисовать в сборке проекта, этот дефайн отключает рисование. Включить или выключить можно так же в окне настроек DebugX.
+ `DEBUGX_DISABLE_INBUILD` - По умолчанию Gizmo будут рисовать в сборке проекта, этот дефайн отключает рисование.
+ `DEBUGX_ENABLE_PHYSICS2D` - Включает Gizmos для Physics2D.
+ `DEBUGX_ENABLE_PHYSICS3D` - Включает Gizmos для Physics3D.

View File

@ -154,7 +154,7 @@ public struct SomeMesh : IStaticMesh
# 设置 # 设置
设置窗口位于 "Tools -> DebugX -> Settings" 设置窗口位于 "Tools -> DebugX -> Settings"
![image](https://github.com/user-attachments/assets/dee3954a-1c8a-442c-a4bb-d2c710e065a4) ![image](https://github.com/user-attachments/assets/7dd981c1-1e00-4b7d-9a73-376638094689)
<br> <br>
@ -256,7 +256,4 @@ SomeAssets assets = DebugXUtility.LoadStaticData(new SomeAssets(), "SomeAssets")
<br> <br>
# Define Symbols # Define Symbols
All Define Symbols can be changed in the settings window + `DISABLE_DEBUGX_INBUILD` - By default, Gizmos will be drawn in the project build. This define disables drawing. It can also be enabled or disabled in the DebugX settings window.
+ `DEBUGX_DISABLE_INBUILD` - By default, Gizmos will be drawn in the project build. This define disables drawing.
+ `DEBUGX_ENABLE_PHYSICS2D` - Enable Physics2D Gizmos.
+ `DEBUGX_ENABLE_PHYSICS3D` - Enable Physics3D Gizmos.

View File

@ -39,7 +39,7 @@
</br> </br>
A multifunctional, extensible, and high-performance Gizmos drawing utility for Unity. It works both in the editor and in the build, and drawing can be done both in `OnDrawGizmos` and in `Update`. HDRP, URP, and BRP are supported, but drawing in the `OnDrawGizmos` callbacks is not supported in BRP. A multifunctional, extensible, and high-performance Gizmos drawing utility for Unity. It works both in the editor and in the build, and drawing can be done both in OnDrawGizmos and in Update. HDRP, URP, and BRP are supported, but drawing in the OnDrawGizmos callbacks is not supported in BRP.
Syntax: Syntax:
```c# ```c#
@ -150,7 +150,7 @@ public struct SomeMesh : IStaticMesh
# Settings # Settings
Settings window "Tools -> DebugX -> Settings": Settings window "Tools -> DebugX -> Settings":
![image](https://github.com/user-attachments/assets/dee3954a-1c8a-442c-a4bb-d2c710e065a4) ![image](https://github.com/user-attachments/assets/7dd981c1-1e00-4b7d-9a73-376638094689)
<br> <br>
@ -252,7 +252,4 @@ SomeAssets assets = DebugXUtility.LoadStaticData(new SomeAssets(), "SomeAssets")
<br> <br>
# Define Symbols # Define Symbols
All Define Symbols can be changed in the settings window + `DISABLE_DEBUGX_INBUILD` - By default, Gizmos will be drawn in the project build. This define disables drawing. It can also be enabled or disabled in the DebugX settings window.
+ `DEBUGX_DISABLE_INBUILD` - By default, Gizmos will be drawn in the project build. This define disables drawing.
+ `DEBUGX_ENABLE_PHYSICS2D` - Enable Physics2D Gizmos.
+ `DEBUGX_ENABLE_PHYSICS3D` - Enable Physics3D Gizmos.

View File

@ -47,20 +47,8 @@ namespace DCFApixels.DebugXCore
{ {
public static class DebugXDefines public static class DebugXDefines
{ {
public const bool DEBUGX_DISABLE_INBUILD = public const bool DISABLE_DEBUGX_INBUILD =
#if DEBUGX_DISABLE_INBUILD #if DISABLE_DEBUGX_INBUILD
true;
#else
false;
#endif
public const bool DEBUGX_ENABLE_PHYSICS2D =
#if DEBUGX_ENABLE_PHYSICS2D
true;
#else
false;
#endif
public const bool DEBUGX_ENABLE_PHYSICS3D =
#if DEBUGX_ENABLE_PHYSICS3D
true; true;
#else #else
false; false;

View File

@ -10,7 +10,6 @@ namespace DCFApixels
private const float ShadowAlphaMultiplier = 0.3f; private const float ShadowAlphaMultiplier = 0.3f;
public readonly partial struct DrawHandler public readonly partial struct DrawHandler
{ {
#if DEBUGX_ENABLE_PHYSICS3D
#region RaycastHit #region RaycastHit
[IN(LINE)] [IN(LINE)]
public DrawHandler RaycastHit(RaycastHit hit) public DrawHandler RaycastHit(RaycastHit hit)
@ -22,8 +21,25 @@ namespace DCFApixels
} }
return this; return this;
} }
[IN(LINE)]
public DrawHandler RaycastHit(RaycastHit2D hit)
{
if (hit.collider != null)
{
DotDiamond(hit.point);
RayArrow(hit.point, hit.normal);
}
return this;
}
[IN(LINE)]
private void RaycastHit_Internal(float offsetZ, RaycastHit2D hit)
{
DotDiamond(new Vector3(hit.point.x, hit.point.y, offsetZ));
RayArrow(new Vector3(hit.point.x, hit.point.y, offsetZ), hit.normal);
}
#endregion #endregion
#region Raycast #region Raycast
[IN(LINE)] public DrawHandler Raycast(Ray ray, RaycastHit hit) => Raycast(ray.origin, ray.direction, hit); [IN(LINE)] public DrawHandler Raycast(Ray ray, RaycastHit hit) => Raycast(ray.origin, ray.direction, hit);
[IN(LINE)] [IN(LINE)]
@ -127,27 +143,7 @@ namespace DCFApixels
return this; return this;
} }
#endregion #endregion
#endif
#if DEBUGX_ENABLE_PHYSICS2D
#region RaycastHit2D
[IN(LINE)]
public DrawHandler RaycastHit(RaycastHit2D hit)
{
if (hit.collider != null)
{
DotDiamond(hit.point);
RayArrow(hit.point, hit.normal);
}
return this;
}
[IN(LINE)]
private void RaycastHit_Internal(float offsetZ, RaycastHit2D hit)
{
DotDiamond(new Vector3(hit.point.x, hit.point.y, offsetZ));
RayArrow(new Vector3(hit.point.x, hit.point.y, offsetZ), hit.normal);
}
#endregion
#region Raycast2D #region Raycast2D
[IN(LINE)] public DrawHandler Raycast2D(Ray ray, RaycastHit2D hit) => Raycast2D(ray.origin, ray.direction, hit); [IN(LINE)] public DrawHandler Raycast2D(Ray ray, RaycastHit2D hit) => Raycast2D(ray.origin, ray.direction, hit);
@ -242,7 +238,6 @@ namespace DCFApixels
return this; return this;
} }
#endregion #endregion
#endif
} }
} }
} }

View File

@ -23,7 +23,6 @@ namespace DCFApixels.DebugXCore.Samples
private void Draw() private void Draw()
{ {
#if DEBUGX_ENABLE_PHYSICS2D
int i = 0; int i = 0;
const float RADIUS_M = 0.5f; const float RADIUS_M = 0.5f;
@ -50,7 +49,6 @@ namespace DCFApixels.DebugXCore.Samples
ray = new Ray(point.position, point.forward); ray = new Ray(point.position, point.forward);
hit = Physics2D.CapsuleCast(ray.origin, point.localScale, CapsuleDirection2D.Vertical, point.eulerAngles.z, ray.direction, float.PositiveInfinity, int.MaxValue); hit = Physics2D.CapsuleCast(ray.origin, point.localScale, CapsuleDirection2D.Vertical, point.eulerAngles.z, ray.direction, float.PositiveInfinity, int.MaxValue);
DebugX.Draw(GetColor(point)).CapsuleCast2D(ray, point.eulerAngles.z, point.localScale, CapsuleDirection2D.Vertical, hit); DebugX.Draw(GetColor(point)).CapsuleCast2D(ray, point.eulerAngles.z, point.localScale, CapsuleDirection2D.Vertical, hit);
#endif
} }
private Color GetColor(Transform pos1) private Color GetColor(Transform pos1)
{ {

View File

@ -9,8 +9,6 @@ namespace DCFApixels.DebugXCore.Samples
public float GradientMultiplier = 5; public float GradientMultiplier = 5;
public Transform[] Points; public Transform[] Points;
#if UNITY_EDITOR #if UNITY_EDITOR
private void OnDrawGizmos() private void OnDrawGizmos()
{ {
@ -25,7 +23,6 @@ namespace DCFApixels.DebugXCore.Samples
private void Draw() private void Draw()
{ {
#if DEBUGX_ENABLE_PHYSICS3D
int i = 0; int i = 0;
const float RADIUS_M = 0.5f; const float RADIUS_M = 0.5f;
@ -54,7 +51,6 @@ namespace DCFApixels.DebugXCore.Samples
Vector3 point2 = ray.origin + point.up * point.localScale.y * RADIUS_M * -0.5f; Vector3 point2 = ray.origin + point.up * point.localScale.y * RADIUS_M * -0.5f;
Physics.CapsuleCast(point1, point2, point.localScale.x * RADIUS_M, ray.direction, out hit, float.PositiveInfinity, int.MaxValue, QueryTriggerInteraction.UseGlobal); Physics.CapsuleCast(point1, point2, point.localScale.x * RADIUS_M, ray.direction, out hit, float.PositiveInfinity, int.MaxValue, QueryTriggerInteraction.UseGlobal);
DebugX.Draw(GetColor(point)).CapsuleCast(point1, point2, ray.direction, point.localScale.x * RADIUS_M, hit); DebugX.Draw(GetColor(point)).CapsuleCast(point1, point2, ray.direction, point.localScale.x * RADIUS_M, hit);
#endif
} }
private Color GetColor(Transform pos1) private Color GetColor(Transform pos1)
{ {

View File

@ -8,7 +8,7 @@
"displayName": "DebugX", "displayName": "DebugX",
"description": "", "description": "",
"unity": "2021.3", "unity": "2021.3",
"version": "0.8.9", "version": "0.8.7",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/DCFApixels/DebugX.git" "url": "https://github.com/DCFApixels/DebugX.git"