mirror of
https://github.com/DCFApixels/Unity-DebugX.git
synced 2025-09-18 01:54:37 +08:00
Compare commits
15 Commits
e4cd108ad9
...
e470b229bc
Author | SHA1 | Date | |
---|---|---|---|
![]() |
e470b229bc | ||
![]() |
b6ef1b984b | ||
![]() |
aefcdc69ab | ||
![]() |
9e966edb31 | ||
![]() |
4b709366d9 | ||
![]() |
89427b41f9 | ||
![]() |
f7bc2def04 | ||
![]() |
3ee671aed5 | ||
![]() |
c6e1acc697 | ||
![]() |
587500061e | ||
![]() |
e3341988b0 | ||
![]() |
964ba7e3df | ||
![]() |
fe5142dbdc | ||
![]() |
809a04c8fb | ||
![]() |
60b2e0ea21 |
@ -27,9 +27,11 @@ namespace DCFApixels.DebugXCore.Internal
|
|||||||
//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.DEBUGX_DISABLE_INBUILD);
|
||||||
private static (string name, bool flag)[] _defines = null;
|
private static (string name, bool flag)[] _defines = null;
|
||||||
|
private static Vector2 _pos;
|
||||||
|
|
||||||
private void OnGUI()
|
private void OnGUI()
|
||||||
{
|
{
|
||||||
|
_pos = GUILayout.BeginScrollView(_pos, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
|
||||||
float tmpValue;
|
float tmpValue;
|
||||||
|
|
||||||
DebugX.GlobalTimeScale = EditorGUILayout.FloatField("TimeScale", DebugX.GlobalTimeScale);
|
DebugX.GlobalTimeScale = EditorGUILayout.FloatField("TimeScale", DebugX.GlobalTimeScale);
|
||||||
@ -53,6 +55,23 @@ namespace DCFApixels.DebugXCore.Internal
|
|||||||
color.a = EditorGUILayout.Slider(DebugX.GlobalColor.a, 0, 1);
|
color.a = EditorGUILayout.Slider(DebugX.GlobalColor.a, 0, 1);
|
||||||
DebugX.GlobalColor = color;
|
DebugX.GlobalColor = color;
|
||||||
|
|
||||||
|
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();
|
||||||
|
|
||||||
GUILayout.BeginVertical(EditorStyles.helpBox);
|
GUILayout.BeginVertical(EditorStyles.helpBox);
|
||||||
GUILayout.Label("Scripting Define Symbols", EditorStyles.helpBox);
|
GUILayout.Label("Scripting Define Symbols", EditorStyles.helpBox);
|
||||||
@ -71,72 +90,18 @@ namespace DCFApixels.DebugXCore.Internal
|
|||||||
}
|
}
|
||||||
GUILayout.EndVertical();
|
GUILayout.EndVertical();
|
||||||
|
|
||||||
// if (_isCompilation == false)
|
GUILayout.EndScrollView();
|
||||||
// {
|
}
|
||||||
// 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;
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
private void DrawReadonlyLeftToggle(string text, bool value)
|
||||||
|
{
|
||||||
|
GUILayout.BeginHorizontal();
|
||||||
if (GUILayout.Button("Reset"))
|
bool GUI_enabled_default = GUI.enabled;
|
||||||
{
|
GUI.enabled = false;
|
||||||
DebugX.ResetGlobals();
|
EditorGUILayout.Toggle(value, GUILayout.Width(14), GUILayout.ExpandWidth(false));
|
||||||
}
|
GUI.enabled = GUI_enabled_default;
|
||||||
|
EditorGUILayout.LabelField(text, GUILayout.ExpandWidth(true));
|
||||||
if (GUILayout.Button("Clear All Gizmos"))
|
GUILayout.EndHorizontal();
|
||||||
{
|
|
||||||
DebugX.ClearAllGizmos();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,11 +64,15 @@ DebugX.Draw(duration, color).*Gizmo Function*(...);
|
|||||||
# Установка
|
# Установка
|
||||||
Семантика версионирования - [Открыть](https://gist.github.com/DCFApixels/e53281d4628b19fe5278f3e77a7da9e8#file-dcfapixels_versioning_ru-md)
|
Семантика версионирования - [Открыть](https://gist.github.com/DCFApixels/e53281d4628b19fe5278f3e77a7da9e8#file-dcfapixels_versioning_ru-md)
|
||||||
### Unity-Package
|
### Unity-Package
|
||||||
Поддерживается установка в виде Unity-модуля, достаточно скопировать Git-URL [в PackageManager](https://docs.unity3d.com/2023.2/Documentation/Manual/upm-ui-giturl.html) или в `Packages/manifest.json`. Скопируйте этот Git-URL для установки актуальной рабочей версии:
|
Поддерживается установка в виде Unity-модуля, достаточно добавить [в PackageManager](https://docs.unity3d.com/2023.2/Documentation/Manual/upm-ui-giturl.html) этот Git-URL :
|
||||||
```
|
```
|
||||||
https://github.com/DCFApixels/Unity-DebugX.git
|
https://github.com/DCFApixels/Unity-DebugX.git
|
||||||
```
|
```
|
||||||
### 作为源代码
|
Или скопировать в `Packages/manifest.json` эту строчку:
|
||||||
|
```
|
||||||
|
"com.dcfa_pixels.debugx": "https://github.com/DCFApixels/Unity-DebugX.git"
|
||||||
|
```
|
||||||
|
### В виде исходников
|
||||||
Пакет так же может быть напрямую скопирован в папку проекта.
|
Пакет так же может быть напрямую скопирован в папку проекта.
|
||||||
|
|
||||||
</br>
|
</br>
|
||||||
|
@ -63,10 +63,15 @@ DebugX.Draw(duration, color).*Gizmo Function*(...);
|
|||||||
# Installation
|
# Installation
|
||||||
Versioning semantics - [Открыть](https://gist.github.com/DCFApixels/e53281d4628b19fe5278f3e77a7da9e8#file-dcfapixels_versioning_ru-md)
|
Versioning semantics - [Открыть](https://gist.github.com/DCFApixels/e53281d4628b19fe5278f3e77a7da9e8#file-dcfapixels_versioning_ru-md)
|
||||||
### Unity-Package
|
### Unity-Package
|
||||||
Supports installation as a Unity module. Copy the Git-URL [into PackageManager](https://docs.unity3d.com/2023.2/Documentation/Manual/upm-ui-giturl.html) or into `Packages/manifest.json`. Copy this Git-URL to install the latest working version:
|
Supports installation as a Unity module. Copy the Git-URL [into PackageManager](https://docs.unity3d.com/2023.2/Documentation/Manual/upm-ui-giturl.html):
|
||||||
```
|
```
|
||||||
https://github.com/DCFApixels/Unity-DebugX.git
|
https://github.com/DCFApixels/Unity-DebugX.git
|
||||||
```
|
```
|
||||||
|
Alternatively, copy this line into `Packages/manifest.json`:
|
||||||
|
```
|
||||||
|
"com.dcfa_pixels.debugx": "https://github.com/DCFApixels/Unity-DebugX.git"
|
||||||
|
```
|
||||||
|
|
||||||
### Source Code
|
### Source Code
|
||||||
The Package can also be directly copied into the project folder.
|
The Package can also be directly copied into the project folder.
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ using UnityEngine.Rendering;
|
|||||||
|
|
||||||
namespace DCFApixels
|
namespace DCFApixels
|
||||||
{
|
{
|
||||||
|
//TODO для разработки аналога Handlers.DrawWireArc можно посмотреть в сторону того чтобы на уровне шейдера делать пиксели прозрачными
|
||||||
public static class DebugXConsts
|
public static class DebugXConsts
|
||||||
{
|
{
|
||||||
public const float IMMEDIATE_DURATION = -1;
|
public const float IMMEDIATE_DURATION = -1;
|
||||||
|
@ -198,10 +198,18 @@ namespace DCFApixels
|
|||||||
{
|
{
|
||||||
return new DrawHandler(GetCurrentDefaultDuration(), color);
|
return new DrawHandler(GetCurrentDefaultDuration(), color);
|
||||||
}
|
}
|
||||||
|
public static DrawHandler Draw((Color color, float alphaMultiplier) color)
|
||||||
|
{
|
||||||
|
return new DrawHandler(GetCurrentDefaultDuration(), color.ToColor());
|
||||||
|
}
|
||||||
public static DrawHandler Draw(float duration, Color color)
|
public static DrawHandler Draw(float duration, Color color)
|
||||||
{
|
{
|
||||||
return new DrawHandler(duration, color);
|
return new DrawHandler(duration, color);
|
||||||
}
|
}
|
||||||
|
public static DrawHandler Draw(float duration, (Color color, float alphaMultiplier) color)
|
||||||
|
{
|
||||||
|
return new DrawHandler(duration, color.ToColor());
|
||||||
|
}
|
||||||
//public static DrawHandler Draw(float r, float g, float b, float a = 1f) //TODO
|
//public static DrawHandler Draw(float r, float g, float b, float a = 1f) //TODO
|
||||||
|
|
||||||
public readonly partial struct DrawHandler
|
public readonly partial struct DrawHandler
|
||||||
@ -221,8 +229,10 @@ namespace DCFApixels
|
|||||||
//ContextController = GetCurrenRenderContextController();
|
//ContextController = GetCurrenRenderContextController();
|
||||||
}
|
}
|
||||||
[IN(LINE)] public DrawHandler Setup(float duration, Color color) => new DrawHandler(duration, color);
|
[IN(LINE)] public DrawHandler Setup(float duration, Color color) => new DrawHandler(duration, color);
|
||||||
|
[IN(LINE)] public DrawHandler Setup(float duration, (Color color, float alphaMultiplier) color) => new DrawHandler(duration, color.ToColor());
|
||||||
[IN(LINE)] public DrawHandler Setup(float duration) => new DrawHandler(duration, Color);
|
[IN(LINE)] public DrawHandler Setup(float duration) => new DrawHandler(duration, Color);
|
||||||
[IN(LINE)] public DrawHandler Setup(Color color) => new DrawHandler(Duration, color);
|
[IN(LINE)] public DrawHandler Setup(Color color) => new DrawHandler(Duration, color);
|
||||||
|
[IN(LINE)] public DrawHandler Setup((Color color, float alphaMultiplier) color) => new DrawHandler(Duration, color.ToColor());
|
||||||
//[IN(LINE)]
|
//[IN(LINE)]
|
||||||
//private DrawHandler(float time, Color color, RenderContextController contextController)
|
//private DrawHandler(float time, Color color, RenderContextController contextController)
|
||||||
//{
|
//{
|
||||||
|
@ -43,7 +43,7 @@ namespace DCFApixels
|
|||||||
//}
|
//}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Mesh //TODO потестить
|
#region Mesh
|
||||||
[IN(LINE)]
|
[IN(LINE)]
|
||||||
public DrawHandler Mesh<TMat>(Mesh mesh, Vector3 position, Quaternion rotation, Vector3 size)
|
public DrawHandler Mesh<TMat>(Mesh mesh, Vector3 position, Quaternion rotation, Vector3 size)
|
||||||
where TMat : struct, IStaticMaterial
|
where TMat : struct, IStaticMaterial
|
||||||
@ -92,7 +92,7 @@ namespace DCFApixels
|
|||||||
{
|
{
|
||||||
Mesh = mesh;
|
Mesh = mesh;
|
||||||
Position = position;
|
Position = position;
|
||||||
Rotation = rotation;
|
Rotation = rotation.CheckQuaternionOrDefault();
|
||||||
Size = size;
|
Size = size;
|
||||||
}
|
}
|
||||||
public IGizmoRenderer<MeshGizmo<TMat>> RegisterNewRenderer() { return new Renderer(); }
|
public IGizmoRenderer<MeshGizmo<TMat>> RegisterNewRenderer() { return new Renderer(); }
|
||||||
@ -146,7 +146,7 @@ namespace DCFApixels
|
|||||||
public readonly Vector3 Size;
|
public readonly Vector3 Size;
|
||||||
public InstancingMeshGizmoLayout(Vector3 position, Quaternion rotation, Vector3 size)
|
public InstancingMeshGizmoLayout(Vector3 position, Quaternion rotation, Vector3 size)
|
||||||
{
|
{
|
||||||
Rotation = rotation;
|
Rotation = rotation.CheckQuaternionOrDefault();
|
||||||
Position = position;
|
Position = position;
|
||||||
Size = size;
|
Size = size;
|
||||||
}
|
}
|
||||||
|
64
Runtime/Gizmos/DebugX.other.cs
Normal file
64
Runtime/Gizmos/DebugX.other.cs
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
using DCFApixels.DebugXCore;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.Rendering;
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
using UnityEditor;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace DCFApixels
|
||||||
|
{
|
||||||
|
public static class WireArcGizmosExtensions
|
||||||
|
{
|
||||||
|
public static DebugX.DrawHandler WireArc(this DebugX.DrawHandler self, Vector3 center, Vector3 normal, Vector3 from, float angle, float radius)
|
||||||
|
{
|
||||||
|
return self.Gizmo(new WireArcGizmos(center, normal, from, angle, radius));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace DCFApixels.DebugXCore
|
||||||
|
{
|
||||||
|
using static DebugX;
|
||||||
|
using IN = System.Runtime.CompilerServices.MethodImplAttribute;
|
||||||
|
public struct WireArcGizmos : IGizmo<WireArcGizmos>
|
||||||
|
{
|
||||||
|
public readonly Vector3 Position;
|
||||||
|
public readonly Vector3 Normal;
|
||||||
|
public readonly Vector3 From;
|
||||||
|
public readonly float Angle;
|
||||||
|
public readonly float Radius;
|
||||||
|
[IN(LINE)]
|
||||||
|
public WireArcGizmos(Vector3 position, Vector3 normal, Vector3 from, float angle, float radius)
|
||||||
|
{
|
||||||
|
Position = position;
|
||||||
|
Normal = normal.CheckNormalOrDefault();
|
||||||
|
From = from;
|
||||||
|
Angle = angle;
|
||||||
|
Radius = radius;
|
||||||
|
}
|
||||||
|
public IGizmoRenderer<WireArcGizmos> RegisterNewRenderer()
|
||||||
|
{
|
||||||
|
return new Renderer();
|
||||||
|
}
|
||||||
|
|
||||||
|
private class Renderer : IGizmoRenderer<WireArcGizmos>
|
||||||
|
{
|
||||||
|
public int ExecuteOrder => default(WireMat).GetExecuteOrder();
|
||||||
|
public bool IsStaticRender => false;
|
||||||
|
public void Prepare(Camera camera, GizmosList<WireArcGizmos> list) { }
|
||||||
|
public void Render(Camera camera, GizmosList<WireArcGizmos> list, CommandBuffer cb)
|
||||||
|
{
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
Color handles_color = Handles.color;
|
||||||
|
foreach (var gizmo in list)
|
||||||
|
{
|
||||||
|
Handles.color = gizmo.Color;
|
||||||
|
Handles.DrawWireArc(gizmo.Value.Position, gizmo.Value.Normal, gizmo.Value.From, gizmo.Value.Angle, gizmo.Value.Radius);
|
||||||
|
}
|
||||||
|
Handles.color = handles_color;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
2
Runtime/Gizmos/DebugX.other.cs.meta
Normal file
2
Runtime/Gizmos/DebugX.other.cs.meta
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c3f0e370bd83bef4a8955d9f9979ce01
|
@ -12,16 +12,40 @@ namespace DCFApixels
|
|||||||
public readonly partial struct DrawHandler
|
public readonly partial struct DrawHandler
|
||||||
{
|
{
|
||||||
#region BillboardCircle
|
#region BillboardCircle
|
||||||
[IN(LINE)] public DrawHandler BillboardCircle(Vector3 position, float radius) => Mesh<CircleMesh, BillboardMat>(position, Quaternion.identity, new Vector3(radius, radius, radius));
|
[IN(LINE)]
|
||||||
|
public DrawHandler BillboardCircle(Vector3 position, float radius)
|
||||||
|
{
|
||||||
|
return Mesh<CircleMesh, BillboardMat>(position, Quaternion.identity, new Vector3(radius, radius, radius));
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Cross
|
#region BillboardCross
|
||||||
[IN(LINE)] public DrawHandler Cross(Vector3 position, float size) => Mesh<DotCrossMesh, BillboardMat>(position, Quaternion.identity, new Vector3(size, size, size));
|
[IN(LINE)]
|
||||||
|
[Obsolete("Use BillboardCross(position, size)")]
|
||||||
|
public DrawHandler Cross(Vector3 position, float size)
|
||||||
|
{
|
||||||
|
return Mesh<DotCrossMesh, BillboardMat>(position, Quaternion.identity, new Vector3(size, size, size));
|
||||||
|
}
|
||||||
|
[IN(LINE)]
|
||||||
|
public DrawHandler BillboardCross(Vector3 position, float size)
|
||||||
|
{
|
||||||
|
return Mesh<DotCrossMesh, BillboardMat>(position, Quaternion.identity, new Vector3(size, size, size));
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
#region Sphere
|
#region Sphere
|
||||||
[IN(LINE)] public DrawHandler Sphere(Vector3 position, float radius) => Mesh<SphereMesh, LitMat>(position, Quaternion.identity, new Vector3(radius, radius, radius));
|
[IN(LINE)]
|
||||||
|
public DrawHandler Sphere<TMat>(Vector3 position, float radius)
|
||||||
|
where TMat : struct, IStaticMaterial
|
||||||
|
{
|
||||||
|
return Mesh<SphereMesh, TMat>(position, Quaternion.identity, new Vector3(radius, radius, radius));
|
||||||
|
}
|
||||||
|
[IN(LINE)]
|
||||||
|
public DrawHandler Sphere(Vector3 position, float radius)
|
||||||
|
{
|
||||||
|
return Mesh<SphereMesh>(position, Quaternion.identity, new Vector3(radius, radius, radius));
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region WireSphere
|
#region WireSphere
|
||||||
@ -107,9 +131,30 @@ namespace DCFApixels
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
#region Circle
|
#region Circle
|
||||||
[IN(LINE)] public DrawHandler Circle(Vector3 position, Vector3 normal, float radius) => Mesh<CircleMesh, LitMat>(position, Quaternion.LookRotation(normal), new Vector3(radius, radius, radius));
|
[IN(LINE)]
|
||||||
[IN(LINE)] public DrawHandler Circle(Vector3 position, Quaternion rotation, float radius) => Mesh<CircleMesh, LitMat>(position, rotation, new Vector3(radius, radius, radius));
|
public DrawHandler Circle<TMat>(Vector3 position, Vector3 normal, float radius)
|
||||||
|
where TMat : struct, IStaticMaterial
|
||||||
|
{
|
||||||
|
return Mesh<CircleMesh, TMat>(position, Quaternion.LookRotation(normal.CheckNormalOrDefault()), new Vector3(radius, radius, radius));
|
||||||
|
}
|
||||||
|
[IN(LINE)]
|
||||||
|
public DrawHandler Circle<TMat>(Vector3 position, Quaternion rotation, float radius)
|
||||||
|
where TMat : struct, IStaticMaterial
|
||||||
|
{
|
||||||
|
return Mesh<CircleMesh, TMat>(position, rotation, new Vector3(radius, radius, radius));
|
||||||
|
}
|
||||||
|
[IN(LINE)]
|
||||||
|
public DrawHandler Circle(Vector3 position, Vector3 normal, float radius)
|
||||||
|
{
|
||||||
|
return Mesh<CircleMesh>(position, Quaternion.LookRotation(normal.CheckNormalOrDefault()), new Vector3(radius, radius, radius));
|
||||||
|
}
|
||||||
|
[IN(LINE)]
|
||||||
|
public DrawHandler Circle(Vector3 position, Quaternion rotation, float radius)
|
||||||
|
{
|
||||||
|
return Mesh<CircleMesh>(position, rotation, new Vector3(radius, radius, radius));
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region WireCircle
|
#region WireCircle
|
||||||
@ -120,10 +165,15 @@ namespace DCFApixels
|
|||||||
|
|
||||||
#region Cylinder
|
#region Cylinder
|
||||||
[IN(LINE)]
|
[IN(LINE)]
|
||||||
|
public DrawHandler Cylinder<TMat>(Vector3 position, Quaternion rotation, float radius, float height)
|
||||||
|
where TMat : struct, IStaticMaterial
|
||||||
|
{
|
||||||
|
return Mesh<CylinderMesh, TMat>(position, rotation * Quaternion.Euler(-90, 0, 0), new Vector3(radius * 2f, radius * 2f, height));
|
||||||
|
}
|
||||||
|
[IN(LINE)]
|
||||||
public DrawHandler Cylinder(Vector3 position, Quaternion rotation, float radius, float height)
|
public DrawHandler Cylinder(Vector3 position, Quaternion rotation, float radius, float height)
|
||||||
{
|
{
|
||||||
Mesh<CylinderMesh, LitMat>(position, rotation * Quaternion.Euler(-90, 0, 0), new Vector3(radius * 2f, radius * 2f, height));
|
return Mesh<CylinderMesh>(position, rotation * Quaternion.Euler(-90, 0, 0), new Vector3(radius * 2f, radius * 2f, height));
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -169,12 +219,18 @@ namespace DCFApixels
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
#region Cone
|
#region Cone
|
||||||
[IN(LINE)]
|
[IN(LINE)]
|
||||||
|
public DrawHandler Cone<TMat>(Vector3 position, Quaternion rotation, float radius, float height)
|
||||||
|
where TMat : struct, IStaticMaterial
|
||||||
|
{
|
||||||
|
return Mesh<ConeMesh, TMat>(position, rotation * Quaternion.Euler(-90, 0, 0), new Vector3(radius * 2f, radius * 2f, height));
|
||||||
|
}
|
||||||
|
[IN(LINE)]
|
||||||
public DrawHandler Cone(Vector3 position, Quaternion rotation, float radius, float height)
|
public DrawHandler Cone(Vector3 position, Quaternion rotation, float radius, float height)
|
||||||
{
|
{
|
||||||
Mesh<ConeMesh, LitMat>(position, rotation * Quaternion.Euler(-90, 0, 0), new Vector3(radius * 2f, radius * 2f, height));
|
return Mesh<ConeMesh>(position, rotation * Quaternion.Euler(-90, 0, 0), new Vector3(radius * 2f, radius * 2f, height));
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -215,12 +271,18 @@ namespace DCFApixels
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
#region Triangle
|
#region Triangle
|
||||||
[IN(LINE)]
|
[IN(LINE)]
|
||||||
|
public DrawHandler Triangle<TMat>(Vector3 position, Quaternion rotation, Vector2 size)
|
||||||
|
where TMat : struct, IStaticMaterial
|
||||||
|
{
|
||||||
|
return Mesh<TriangleMesh, TMat>(position, rotation, new Vector3(size.x, size.y, 1f));
|
||||||
|
}
|
||||||
|
[IN(LINE)]
|
||||||
public DrawHandler Triangle(Vector3 position, Quaternion rotation, Vector2 size)
|
public DrawHandler Triangle(Vector3 position, Quaternion rotation, Vector2 size)
|
||||||
{
|
{
|
||||||
Mesh<TriangleMesh, LitMat>(position, rotation, new Vector3(size.x, size.y, 1f));
|
return Mesh<TriangleMesh>(position, rotation, new Vector3(size.x, size.y, 1f));
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -236,7 +298,8 @@ namespace DCFApixels
|
|||||||
|
|
||||||
#region Capsule
|
#region Capsule
|
||||||
[IN(LINE)]
|
[IN(LINE)]
|
||||||
public DrawHandler Capsule(Vector3 position, Quaternion rotation, float radius, float height)
|
public DrawHandler Capsule<TMat>(Vector3 position, Quaternion rotation, float radius, float height)
|
||||||
|
where TMat : struct, IStaticMaterial
|
||||||
{
|
{
|
||||||
radius = Mathf.Max(0, radius);
|
radius = Mathf.Max(0, radius);
|
||||||
height -= radius * 2f;
|
height -= radius * 2f;
|
||||||
@ -244,11 +307,16 @@ namespace DCFApixels
|
|||||||
var halfHeigth = height * 0.5f;
|
var halfHeigth = height * 0.5f;
|
||||||
var normal = rotation * Vector3.up;
|
var normal = rotation * Vector3.up;
|
||||||
|
|
||||||
Mesh<CapsuleHeadMesh, LitMat>(position + normal * halfHeigth, rotation, new Vector3(radius, radius, radius));
|
Mesh<CapsuleHeadMesh, TMat>(position + normal * halfHeigth, rotation, new Vector3(radius, radius, radius));
|
||||||
Mesh<CapsuleBodyMesh, LitMat>(position, rotation, new Vector3(radius, height, radius));
|
Mesh<CapsuleBodyMesh, TMat>(position, rotation, new Vector3(radius, height, radius));
|
||||||
Mesh<CapsuleHeadMesh, LitMat>(position - normal * halfHeigth, rotation * Quaternion.Euler(0, 0, 180), new Vector3(radius, radius, radius));
|
Mesh<CapsuleHeadMesh, TMat>(position - normal * halfHeigth, rotation * Quaternion.Euler(0, 0, 180), new Vector3(radius, radius, radius));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
[IN(LINE)]
|
||||||
|
public DrawHandler Capsule(Vector3 position, Quaternion rotation, float radius, float height)
|
||||||
|
{
|
||||||
|
return Capsule<LitMat>(position, rotation, radius, height);
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region WireCapsule
|
#region WireCapsule
|
||||||
@ -280,9 +348,11 @@ namespace DCFApixels
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
#region FlatCapsule
|
#region FlatCapsule
|
||||||
[IN(LINE)]
|
[IN(LINE)]
|
||||||
public DrawHandler FlatCapsule(Vector3 position, Quaternion rotation, float radius, float height)
|
public DrawHandler FlatCapsule<TMat>(Vector3 position, Quaternion rotation, float radius, float height)
|
||||||
|
where TMat : struct, IStaticMaterial
|
||||||
{
|
{
|
||||||
radius = Mathf.Max(0, radius);
|
radius = Mathf.Max(0, radius);
|
||||||
height -= radius * 2f;
|
height -= radius * 2f;
|
||||||
@ -290,11 +360,16 @@ namespace DCFApixels
|
|||||||
var halfHeigth = height * 0.5f;
|
var halfHeigth = height * 0.5f;
|
||||||
var normal = rotation * Vector3.up;
|
var normal = rotation * Vector3.up;
|
||||||
|
|
||||||
Mesh<FlatCapsuleHeadMesh, LitMat>(position + normal * halfHeigth, rotation, new Vector3(radius, radius, radius));
|
Mesh<FlatCapsuleHeadMesh, TMat>(position + normal * halfHeigth, rotation, new Vector3(radius, radius, radius));
|
||||||
Mesh<FlatCapsuleBodyMesh, LitMat>(position, rotation, new Vector3(radius, height, radius));
|
Mesh<FlatCapsuleBodyMesh, TMat>(position, rotation, new Vector3(radius, height, radius));
|
||||||
Mesh<FlatCapsuleHeadMesh, LitMat>(position - normal * halfHeigth, rotation * Quaternion.Euler(0, 0, 180), new Vector3(radius, radius, radius));
|
Mesh<FlatCapsuleHeadMesh, TMat>(position - normal * halfHeigth, rotation * Quaternion.Euler(0, 0, 180), new Vector3(radius, radius, radius));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
[IN(LINE)]
|
||||||
|
public DrawHandler FlatCapsule(Vector3 position, Quaternion rotation, float radius, float height)
|
||||||
|
{
|
||||||
|
return FlatCapsule<LitMat>(position, rotation, radius, height);
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region WireFlatCapsule
|
#region WireFlatCapsule
|
||||||
@ -336,8 +411,28 @@ namespace DCFApixels
|
|||||||
#region Cube
|
#region Cube
|
||||||
//[IN(LINE)] public void Cube(Vector3 position, float size) => Cube(position, Quaternion.identity, new Vector3(size, size, size));
|
//[IN(LINE)] public void Cube(Vector3 position, float size) => Cube(position, Quaternion.identity, new Vector3(size, size, size));
|
||||||
//[IN(LINE)] public void Cube(Vector3 position, Vector3 size) => Cube(position, Quaternion.identity, size);
|
//[IN(LINE)] public void Cube(Vector3 position, Vector3 size) => Cube(position, Quaternion.identity, size);
|
||||||
[IN(LINE)] public DrawHandler Cube(Vector3 position, Quaternion rotation, float size) => Mesh<CubeMesh, LitMat>(position, rotation, new Vector3(size, size, size));
|
[IN(LINE)]
|
||||||
[IN(LINE)] public DrawHandler Cube(Vector3 position, Quaternion rotation, Vector3 size) => Mesh<CubeMesh, LitMat>(position, rotation, size);
|
public DrawHandler Cube<TMat>(Vector3 position, Quaternion rotation, float size)
|
||||||
|
where TMat : struct, IStaticMaterial
|
||||||
|
{
|
||||||
|
return Mesh<CubeMesh, TMat>(position, rotation, new Vector3(size, size, size));
|
||||||
|
}
|
||||||
|
[IN(LINE)]
|
||||||
|
public DrawHandler Cube<TMat>(Vector3 position, Quaternion rotation, Vector3 size)
|
||||||
|
where TMat : struct, IStaticMaterial
|
||||||
|
{
|
||||||
|
return Mesh<CubeMesh, TMat>(position, rotation, size);
|
||||||
|
}
|
||||||
|
[IN(LINE)]
|
||||||
|
public DrawHandler Cube(Vector3 position, Quaternion rotation, float size)
|
||||||
|
{
|
||||||
|
return Mesh<CubeMesh>(position, rotation, new Vector3(size, size, size));
|
||||||
|
}
|
||||||
|
[IN(LINE)]
|
||||||
|
public DrawHandler Cube(Vector3 position, Quaternion rotation, Vector3 size)
|
||||||
|
{
|
||||||
|
return Mesh<CubeMesh>(position, rotation, size);
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region WireCube
|
#region WireCube
|
||||||
@ -458,11 +553,32 @@ namespace DCFApixels
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
#region Quad
|
#region Quad
|
||||||
//[IN(LINE)] public DrawHandler Quad(Vector3 position, Vector3 normal, float size) => Mesh(Meshes.Quad, position, Quaternion.LookRotation(normal), new Vector3(size, size, size));
|
//[IN(LINE)] public DrawHandler Quad(Vector3 position, Vector3 normal, float size) => Mesh(Meshes.Quad, position, Quaternion.LookRotation(normal), new Vector3(size, size, size));
|
||||||
//[IN(LINE)] public DrawHandler Quad(Vector3 position, Vector3 normal, Vector2 size) => Mesh(Meshes.Quad, position, Quaternion.LookRotation(normal), size);
|
//[IN(LINE)] public DrawHandler Quad(Vector3 position, Vector3 normal, Vector2 size) => Mesh(Meshes.Quad, position, Quaternion.LookRotation(normal), size);
|
||||||
[IN(LINE)] public DrawHandler Quad(Vector3 position, Quaternion rotation, float size) => Mesh<QuadMesh, LitMat>(position, rotation, new Vector3(size, size, 1f)); //TODO fix quad mesh
|
[IN(LINE)]
|
||||||
[IN(LINE)] public DrawHandler Quad(Vector3 position, Quaternion rotation, Vector2 size) => Mesh<QuadMesh, LitMat>(position, rotation, new Vector3(size.x, size.y, 1f)); //TODO fix quad mesh
|
public DrawHandler Quad<TMat>(Vector3 position, Quaternion rotation, float size)
|
||||||
|
where TMat : struct, IStaticMaterial
|
||||||
|
{
|
||||||
|
return Mesh<QuadMesh, TMat>(position, rotation, new Vector3(size, size, 1f));
|
||||||
|
}
|
||||||
|
[IN(LINE)]
|
||||||
|
public DrawHandler Quad<TMat>(Vector3 position, Quaternion rotation, Vector2 size)
|
||||||
|
where TMat : struct, IStaticMaterial
|
||||||
|
{
|
||||||
|
return Mesh<QuadMesh, TMat>(position, rotation, new Vector3(size.x, size.y, 1f));
|
||||||
|
}
|
||||||
|
[IN(LINE)]
|
||||||
|
public DrawHandler Quad(Vector3 position, Quaternion rotation, float size)
|
||||||
|
{
|
||||||
|
return Mesh<QuadMesh>(position, rotation, new Vector3(size, size, 1f));
|
||||||
|
}
|
||||||
|
[IN(LINE)]
|
||||||
|
public DrawHandler Quad(Vector3 position, Quaternion rotation, Vector2 size)
|
||||||
|
{
|
||||||
|
return Mesh<QuadMesh>(position, rotation, new Vector3(size.x, size.y, 1f));
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region WireQuad
|
#region WireQuad
|
||||||
|
@ -11,6 +11,7 @@ namespace DCFApixels
|
|||||||
public readonly partial struct DrawHandler
|
public readonly partial struct DrawHandler
|
||||||
{
|
{
|
||||||
#if DEBUGX_ENABLE_PHYSICS3D
|
#if DEBUGX_ENABLE_PHYSICS3D
|
||||||
|
|
||||||
#region RaycastHit
|
#region RaycastHit
|
||||||
[IN(LINE)]
|
[IN(LINE)]
|
||||||
public DrawHandler RaycastHit(RaycastHit hit)
|
public DrawHandler RaycastHit(RaycastHit hit)
|
||||||
@ -130,6 +131,7 @@ namespace DCFApixels
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if DEBUGX_ENABLE_PHYSICS2D
|
#if DEBUGX_ENABLE_PHYSICS2D
|
||||||
|
|
||||||
#region RaycastHit2D
|
#region RaycastHit2D
|
||||||
[IN(LINE)]
|
[IN(LINE)]
|
||||||
public DrawHandler RaycastHit(RaycastHit2D hit)
|
public DrawHandler RaycastHit(RaycastHit2D hit)
|
||||||
|
@ -9,5 +9,10 @@ namespace DCFApixels.DebugXCore.Internal
|
|||||||
self.a *= v;
|
self.a *= v;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
public static Color ToColor(ref this (Color color, float alpha) self)
|
||||||
|
{
|
||||||
|
self.color.a *= self.alpha;
|
||||||
|
return self.color;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,15 +31,23 @@ Shader "DCFApixels/DebugX/Handles"
|
|||||||
#pragma instancing_options procedural:setup
|
#pragma instancing_options procedural:setup
|
||||||
|
|
||||||
#include "UnityCG.cginc"
|
#include "UnityCG.cginc"
|
||||||
|
#include "HandlesLibrary.cginc"
|
||||||
|
|
||||||
#if defined(UNITY_PROCEDURAL_INSTANCING_ENABLED)
|
#if defined(UNITY_PROCEDURAL_INSTANCING_ENABLED)
|
||||||
struct InstanceData
|
struct InstanceData
|
||||||
{
|
{
|
||||||
float4x4 m;
|
float4x4 m;
|
||||||
float4 color;
|
float4 color;
|
||||||
};
|
};
|
||||||
StructuredBuffer<InstanceData> _DataBuffer;
|
StructuredBuffer<InstanceData> _DataBuffer;
|
||||||
#endif
|
void setup()
|
||||||
|
{
|
||||||
|
InstanceData data = _DataBuffer[unity_InstanceID];
|
||||||
|
UNITY_MATRIX_M = data.m; //UNITY_MATRIX_M
|
||||||
|
_Color = data.color;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
struct appdata_t
|
struct appdata_t
|
||||||
{
|
{
|
||||||
float4 vertex : POSITION;
|
float4 vertex : POSITION;
|
||||||
@ -58,55 +66,14 @@ Shader "DCFApixels/DebugX/Handles"
|
|||||||
half4 color : COLOR;
|
half4 color : COLOR;
|
||||||
};
|
};
|
||||||
|
|
||||||
float4 _Color;
|
|
||||||
float4 _DebugX_GlobalColor;
|
float4 _DebugX_GlobalColor;
|
||||||
|
|
||||||
void setup()
|
|
||||||
{
|
|
||||||
#if defined(UNITY_PROCEDURAL_INSTANCING_ENABLED)
|
|
||||||
InstanceData data = _DataBuffer[unity_InstanceID];
|
|
||||||
|
|
||||||
UNITY_MATRIX_M = data.m; //UNITY_MATRIX_M
|
|
||||||
_Color = data.color;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if _DOT_ON
|
|
||||||
float _DebugX_GlobalDotSize;
|
|
||||||
float GetHandleSize(float3 objectPosition)
|
|
||||||
{
|
|
||||||
float3 viewDir = normalize(_WorldSpaceCameraPos - objectPosition);
|
|
||||||
|
|
||||||
float distance = length(_WorldSpaceCameraPos - objectPosition);
|
|
||||||
float isOrthographic = UNITY_MATRIX_P[3][3];
|
|
||||||
distance = lerp(distance, 1, isOrthographic);
|
|
||||||
|
|
||||||
float fov = radians(UNITY_MATRIX_P[1][1] * 2.0);
|
|
||||||
float scale = distance * (1 / fov) * 0.015;
|
|
||||||
|
|
||||||
|
|
||||||
return scale * _DebugX_GlobalDotSize;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
v2f vert (appdata_t v)
|
v2f vert (appdata_t v)
|
||||||
{
|
{
|
||||||
v2f o;
|
v2f o;
|
||||||
UNITY_SETUP_INSTANCE_ID(v);
|
UNITY_SETUP_INSTANCE_ID(v);
|
||||||
|
float4x4 M = GET_HANDLE_UNITY_MATRIX_M();
|
||||||
float4x4 M = UNITY_MATRIX_M;
|
|
||||||
#if _DOT_ON
|
|
||||||
float scaleMultiplier = GetHandleSize(mul(UNITY_MATRIX_M, float4(0, 0, 0, 1)).xyz);
|
|
||||||
M._m00 *= scaleMultiplier;
|
|
||||||
M._m11 *= scaleMultiplier;
|
|
||||||
M._m22 *= scaleMultiplier;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#if _BILLBOARD_ON
|
#if _BILLBOARD_ON
|
||||||
float4 worldOrigin = mul(M, float4(0, 0, 0, 1));
|
float4 worldOrigin = mul(M, float4(0, 0, 0, 1));
|
||||||
|
47
Runtime/Shaders/HandlesLibrary.cginc
Normal file
47
Runtime/Shaders/HandlesLibrary.cginc
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
float GetHandleSize(float3 objectPosition, float scaleM)
|
||||||
|
{
|
||||||
|
float3 viewDir = normalize(_WorldSpaceCameraPos - objectPosition);
|
||||||
|
|
||||||
|
float distance = length(_WorldSpaceCameraPos - objectPosition);
|
||||||
|
float isOrthographic = UNITY_MATRIX_P[3][3];
|
||||||
|
distance = lerp(distance, 1, isOrthographic);
|
||||||
|
|
||||||
|
float fov = radians(UNITY_MATRIX_P[1][1] * 2.0);
|
||||||
|
float scale = distance * (1 / fov) * 0.015;
|
||||||
|
|
||||||
|
return scale * scaleM;
|
||||||
|
}
|
||||||
|
|
||||||
|
float4x4 GetHandleSizeMatrix(float3 objectPosition, float scaleM)
|
||||||
|
{
|
||||||
|
float4x4 M = UNITY_MATRIX_M;
|
||||||
|
|
||||||
|
float scale = GetHandleSize(objectPosition, scaleM);
|
||||||
|
M._m00 *= scale;
|
||||||
|
M._m11 *= scale;
|
||||||
|
M._m22 *= scale;
|
||||||
|
|
||||||
|
return M;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//Macros
|
||||||
|
#if _DOT_ON
|
||||||
|
float _DebugX_GlobalDotSize;
|
||||||
|
#endif
|
||||||
|
float4 _Color;
|
||||||
|
|
||||||
|
float4x4 GET_HANDLE_UNITY_MATRIX_M()
|
||||||
|
{
|
||||||
|
#if _DOT_ON
|
||||||
|
return GetHandleSizeMatrix(mul(UNITY_MATRIX_M, float4(0, 0, 0, 1)).xyz, _DebugX_GlobalDotSize);
|
||||||
|
#else
|
||||||
|
return UNITY_MATRIX_M;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
7
Runtime/Shaders/HandlesLibrary.cginc.meta
Normal file
7
Runtime/Shaders/HandlesLibrary.cginc.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 728ffe8b3d2321e45a960a3a90e65bc6
|
||||||
|
ShaderIncludeImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -33,15 +33,23 @@ Shader "DCFApixels/DebugX/Handles Overwrite"
|
|||||||
#pragma instancing_options procedural:setup
|
#pragma instancing_options procedural:setup
|
||||||
|
|
||||||
#include "UnityCG.cginc"
|
#include "UnityCG.cginc"
|
||||||
|
#include "HandlesLibrary.cginc"
|
||||||
|
|
||||||
#if defined(UNITY_PROCEDURAL_INSTANCING_ENABLED)
|
#if defined(UNITY_PROCEDURAL_INSTANCING_ENABLED)
|
||||||
struct InstanceData
|
struct InstanceData
|
||||||
{
|
{
|
||||||
float4x4 m;
|
float4x4 m;
|
||||||
float4 color;
|
float4 color;
|
||||||
};
|
};
|
||||||
StructuredBuffer<InstanceData> _DataBuffer;
|
StructuredBuffer<InstanceData> _DataBuffer;
|
||||||
#endif
|
void setup()
|
||||||
|
{
|
||||||
|
InstanceData data = _DataBuffer[unity_InstanceID];
|
||||||
|
UNITY_MATRIX_M = data.m; //UNITY_MATRIX_M
|
||||||
|
_Color = data.color;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
struct appdata_t
|
struct appdata_t
|
||||||
{
|
{
|
||||||
float4 vertex : POSITION;
|
float4 vertex : POSITION;
|
||||||
@ -60,54 +68,13 @@ Shader "DCFApixels/DebugX/Handles Overwrite"
|
|||||||
half4 color : COLOR;
|
half4 color : COLOR;
|
||||||
};
|
};
|
||||||
|
|
||||||
float4 _Color;
|
|
||||||
float4 _DebugX_GlobalColor;
|
float4 _DebugX_GlobalColor;
|
||||||
|
|
||||||
void setup()
|
|
||||||
{
|
|
||||||
#if defined(UNITY_PROCEDURAL_INSTANCING_ENABLED)
|
|
||||||
InstanceData data = _DataBuffer[unity_InstanceID];
|
|
||||||
|
|
||||||
UNITY_MATRIX_M = data.m; //UNITY_MATRIX_M
|
|
||||||
_Color = data.color;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if _DOT_ON
|
|
||||||
float _DebugX_GlobalDotSize;
|
|
||||||
float GetHandleSize(float3 objectPosition)
|
|
||||||
{
|
|
||||||
float3 viewDir = normalize(_WorldSpaceCameraPos - objectPosition);
|
|
||||||
|
|
||||||
float distance = length(_WorldSpaceCameraPos - objectPosition);
|
|
||||||
float isOrthographic = UNITY_MATRIX_P[3][3];
|
|
||||||
distance = lerp(distance, 1, isOrthographic);
|
|
||||||
|
|
||||||
float fov = radians(UNITY_MATRIX_P[1][1] * 2.0);
|
|
||||||
float scale = distance * (1 / fov) * 0.015;
|
|
||||||
|
|
||||||
return scale * _DebugX_GlobalDotSize;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
v2f vert (appdata_t v)
|
v2f vert (appdata_t v)
|
||||||
{
|
{
|
||||||
v2f o;
|
v2f o;
|
||||||
UNITY_SETUP_INSTANCE_ID(v);
|
UNITY_SETUP_INSTANCE_ID(v);
|
||||||
|
float4x4 M = GET_HANDLE_UNITY_MATRIX_M();
|
||||||
float4x4 M = UNITY_MATRIX_M;
|
|
||||||
#if _DOT_ON
|
|
||||||
float scaleMultiplier = GetHandleSize(mul(UNITY_MATRIX_M, float4(0, 0, 0, 1)).xyz);
|
|
||||||
M._m00 *= scaleMultiplier;
|
|
||||||
M._m11 *= scaleMultiplier;
|
|
||||||
M._m22 *= scaleMultiplier;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#if _BILLBOARD_ON
|
#if _BILLBOARD_ON
|
||||||
float4 worldOrigin = mul(M, float4(0, 0, 0, 1));
|
float4 worldOrigin = mul(M, float4(0, 0, 0, 1));
|
||||||
|
@ -32,15 +32,24 @@ Shader "DCFApixels/DebugX/Handles Wire"
|
|||||||
#pragma instancing_options procedural:setup
|
#pragma instancing_options procedural:setup
|
||||||
|
|
||||||
#include "UnityCG.cginc"
|
#include "UnityCG.cginc"
|
||||||
|
#include "HandlesLibrary.cginc"
|
||||||
|
|
||||||
#if defined(UNITY_PROCEDURAL_INSTANCING_ENABLED)
|
#if defined(UNITY_PROCEDURAL_INSTANCING_ENABLED)
|
||||||
struct InstanceData
|
struct InstanceData
|
||||||
{
|
{
|
||||||
float4x4 m;
|
float4x4 m;
|
||||||
float4 color;
|
float4 color;
|
||||||
};
|
};
|
||||||
StructuredBuffer<InstanceData> _DataBuffer;
|
StructuredBuffer<InstanceData> _DataBuffer;
|
||||||
#endif
|
void setup()
|
||||||
|
{
|
||||||
|
InstanceData data = _DataBuffer[unity_InstanceID];
|
||||||
|
UNITY_MATRIX_M = data.m; //UNITY_MATRIX_M
|
||||||
|
_Color = data.color;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
struct appdata_t
|
struct appdata_t
|
||||||
{
|
{
|
||||||
float4 vertex : POSITION;
|
float4 vertex : POSITION;
|
||||||
@ -64,54 +73,14 @@ Shader "DCFApixels/DebugX/Handles Wire"
|
|||||||
float4 color : COLOR;
|
float4 color : COLOR;
|
||||||
};
|
};
|
||||||
|
|
||||||
float4 _Color;
|
|
||||||
float4 _DebugX_GlobalColor;
|
float4 _DebugX_GlobalColor;
|
||||||
|
|
||||||
void setup()
|
|
||||||
{
|
|
||||||
#if defined(UNITY_PROCEDURAL_INSTANCING_ENABLED)
|
|
||||||
InstanceData data = _DataBuffer[unity_InstanceID];
|
|
||||||
|
|
||||||
UNITY_MATRIX_M = data.m; //UNITY_MATRIX_M
|
|
||||||
_Color = data.color;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if _DOT_ON
|
|
||||||
float _DebugX_GlobalDotSize;
|
|
||||||
float GetHandleSize(float3 objectPosition)
|
|
||||||
{
|
|
||||||
float3 viewDir = normalize(_WorldSpaceCameraPos - objectPosition);
|
|
||||||
|
|
||||||
float distance = length(_WorldSpaceCameraPos - objectPosition);
|
|
||||||
float isOrthographic = UNITY_MATRIX_P[3][3];
|
|
||||||
distance = lerp(distance, 1, isOrthographic);
|
|
||||||
|
|
||||||
float fov = radians(UNITY_MATRIX_P[1][1] * 2.0);
|
|
||||||
float scale = distance * (1 / fov) * 0.015;
|
|
||||||
|
|
||||||
return scale * _DebugX_GlobalDotSize;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
v2g vert (appdata_t v)
|
v2g vert (appdata_t v)
|
||||||
{
|
{
|
||||||
v2g o;
|
v2g o;
|
||||||
UNITY_SETUP_INSTANCE_ID(v);
|
UNITY_SETUP_INSTANCE_ID(v);
|
||||||
|
float4x4 M = GET_HANDLE_UNITY_MATRIX_M();
|
||||||
float4x4 M = UNITY_MATRIX_M;
|
|
||||||
#if _DOT_ON
|
|
||||||
float scaleMultiplier = GetHandleSize(mul(UNITY_MATRIX_M, float4(0, 0, 0, 1)).xyz);
|
|
||||||
M._m00 *= scaleMultiplier;
|
|
||||||
M._m11 *= scaleMultiplier;
|
|
||||||
M._m22 *= scaleMultiplier;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#if _BILLBOARD_ON
|
#if _BILLBOARD_ON
|
||||||
float4 worldOrigin = mul(M, float4(0, 0, 0, 1));
|
float4 worldOrigin = mul(M, float4(0, 0, 0, 1));
|
||||||
|
27
Runtime/Utils/ValidationUtils.cs
Normal file
27
Runtime/Utils/ValidationUtils.cs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace DCFApixels.DebugXCore
|
||||||
|
{
|
||||||
|
public static class ValidationUtils
|
||||||
|
{
|
||||||
|
public static Quaternion CheckQuaternionOrDefault(this Quaternion quaternion)
|
||||||
|
{
|
||||||
|
float sqrMagnitude = quaternion.x * quaternion.x + quaternion.y * quaternion.y + quaternion.z * quaternion.z + quaternion.w * quaternion.w;
|
||||||
|
if (float.IsNaN(sqrMagnitude) || (sqrMagnitude < float.Epsilon))
|
||||||
|
{
|
||||||
|
return Quaternion.identity;
|
||||||
|
}
|
||||||
|
return quaternion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector3 CheckNormalOrDefault(this Vector3 normal)
|
||||||
|
{
|
||||||
|
float sqrMagnitude = normal.sqrMagnitude;
|
||||||
|
if (float.IsNaN(sqrMagnitude) || (sqrMagnitude < float.Epsilon))
|
||||||
|
{
|
||||||
|
return Vector3.forward;
|
||||||
|
}
|
||||||
|
return normal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
2
Runtime/Utils/ValidationUtils.cs.meta
Normal file
2
Runtime/Utils/ValidationUtils.cs.meta
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: cfcf280d995044a46b559a8da9d2f25d
|
@ -54,7 +54,9 @@ Shader "DCFApixels/DebugX/Samples/FakeLighth"
|
|||||||
|
|
||||||
fixed4 frag (v2f i) : SV_Target
|
fixed4 frag (v2f i) : SV_Target
|
||||||
{
|
{
|
||||||
return _Color * (1.0 - Unity_PolarCoordinates_float(i.uv, float2(0.5, 0.5), 1, 1).r);
|
float m = (1.0 - Unity_PolarCoordinates_float(i.uv, float2(0.5, 0.5), 1, 1).r);
|
||||||
|
m = clamp(m, 0, 1);
|
||||||
|
return _Color * m;
|
||||||
}
|
}
|
||||||
ENDCG
|
ENDCG
|
||||||
}
|
}
|
||||||
|
@ -622,7 +622,7 @@ MonoBehaviour:
|
|||||||
m_ColorSpace: -1
|
m_ColorSpace: -1
|
||||||
m_NumColorKeys: 3
|
m_NumColorKeys: 3
|
||||||
m_NumAlphaKeys: 2
|
m_NumAlphaKeys: 2
|
||||||
GradientMultiplier: 2
|
GradientMultiplier: 3
|
||||||
Points:
|
Points:
|
||||||
- {fileID: 1728437382}
|
- {fileID: 1728437382}
|
||||||
- {fileID: 54381892}
|
- {fileID: 54381892}
|
||||||
@ -875,6 +875,37 @@ Transform:
|
|||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 2137543453}
|
m_Father: {fileID: 2137543453}
|
||||||
m_LocalEulerAnglesHint: {x: 45, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 45, y: 0, z: 0}
|
||||||
|
--- !u!1 &223293503
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 223293504}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: Warrning
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &223293504
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 223293503}
|
||||||
|
serializedVersion: 2
|
||||||
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: -1.82}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 241950277}
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &227658960
|
--- !u!1 &227658960
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -975,6 +1006,7 @@ Transform:
|
|||||||
- {fileID: 629058557}
|
- {fileID: 629058557}
|
||||||
- {fileID: 1190527457}
|
- {fileID: 1190527457}
|
||||||
- {fileID: 607411204}
|
- {fileID: 607411204}
|
||||||
|
- {fileID: 1275004640}
|
||||||
m_Father: {fileID: 2070085917}
|
m_Father: {fileID: 2070085917}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &239565651
|
--- !u!1 &239565651
|
||||||
@ -1096,6 +1128,7 @@ Transform:
|
|||||||
- {fileID: 1968074010}
|
- {fileID: 1968074010}
|
||||||
- {fileID: 1230489027}
|
- {fileID: 1230489027}
|
||||||
- {fileID: 82819859}
|
- {fileID: 82819859}
|
||||||
|
- {fileID: 223293504}
|
||||||
m_Father: {fileID: 700624119}
|
m_Father: {fileID: 700624119}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &290054995
|
--- !u!1 &290054995
|
||||||
@ -1621,7 +1654,7 @@ MonoBehaviour:
|
|||||||
m_ColorSpace: -1
|
m_ColorSpace: -1
|
||||||
m_NumColorKeys: 3
|
m_NumColorKeys: 3
|
||||||
m_NumAlphaKeys: 2
|
m_NumAlphaKeys: 2
|
||||||
GradientMultiplier: 2
|
GradientMultiplier: 1.5
|
||||||
WidthMultiplier: 1
|
WidthMultiplier: 1
|
||||||
StartLines:
|
StartLines:
|
||||||
- {fileID: 1105319542}
|
- {fileID: 1105319542}
|
||||||
@ -2506,6 +2539,7 @@ MonoBehaviour:
|
|||||||
- {fileID: 1968074010}
|
- {fileID: 1968074010}
|
||||||
- {fileID: 1230489027}
|
- {fileID: 1230489027}
|
||||||
- {fileID: 82819859}
|
- {fileID: 82819859}
|
||||||
|
WarrningPoint: {fileID: 223293504}
|
||||||
--- !u!4 &700624119
|
--- !u!4 &700624119
|
||||||
Transform:
|
Transform:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -3650,6 +3684,37 @@ Transform:
|
|||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 162132448}
|
m_Father: {fileID: 162132448}
|
||||||
m_LocalEulerAnglesHint: {x: 45, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 45, y: 0, z: 0}
|
||||||
|
--- !u!1 &1275004639
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 1275004640}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: Warrning
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &1275004640
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1275004639}
|
||||||
|
serializedVersion: 2
|
||||||
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0.58000004, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 234433271}
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &1302158462
|
--- !u!1 &1302158462
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -5514,7 +5579,7 @@ MonoBehaviour:
|
|||||||
m_ColorSpace: -1
|
m_ColorSpace: -1
|
||||||
m_NumColorKeys: 3
|
m_NumColorKeys: 3
|
||||||
m_NumAlphaKeys: 2
|
m_NumAlphaKeys: 2
|
||||||
GradientMultiplier: 2
|
GradientMultiplier: 3
|
||||||
Points:
|
Points:
|
||||||
- {fileID: 1170244042}
|
- {fileID: 1170244042}
|
||||||
- {fileID: 151432312}
|
- {fileID: 151432312}
|
||||||
@ -5727,6 +5792,7 @@ MonoBehaviour:
|
|||||||
- {fileID: 629058557}
|
- {fileID: 629058557}
|
||||||
- {fileID: 1190527457}
|
- {fileID: 1190527457}
|
||||||
- {fileID: 607411204}
|
- {fileID: 607411204}
|
||||||
|
WarrningPoint: {fileID: 1275004640}
|
||||||
--- !u!4 &2070085917
|
--- !u!4 &2070085917
|
||||||
Transform:
|
Transform:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
using DCFApixels.DebugXCore.Samples.Internal;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace DCFApixels.DebugXCore.Samples
|
namespace DCFApixels.DebugXCore.Samples
|
||||||
@ -39,12 +40,7 @@ namespace DCFApixels.DebugXCore.Samples
|
|||||||
}
|
}
|
||||||
private Color GetColor(Transform pos1, Transform pos2)
|
private Color GetColor(Transform pos1, Transform pos2)
|
||||||
{
|
{
|
||||||
Vector3 pos = (pos1.localPosition + pos2.localPosition) * 0.5f;
|
return Gradient.Evaluate(pos1, pos2, GradientMultiplier);
|
||||||
pos /= GradientMultiplier == 0 ? 1 : GradientMultiplier;
|
|
||||||
pos += Vector3.one * 0.5f;
|
|
||||||
float t = pos.x + pos.y + pos.z;
|
|
||||||
t /= 3f;
|
|
||||||
return Gradient.Evaluate(Mathf.Clamp01(t));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
using DCFApixels.DebugXCore.Samples.Internal;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace DCFApixels.DebugXCore.Samples
|
namespace DCFApixels.DebugXCore.Samples
|
||||||
@ -26,7 +27,7 @@ namespace DCFApixels.DebugXCore.Samples
|
|||||||
int i = -1;
|
int i = -1;
|
||||||
const float RADIUS_M = 0.5f;
|
const float RADIUS_M = 0.5f;
|
||||||
|
|
||||||
i++; DebugX.Draw(GetColor(Points[i])).Cross(Points[i].position, Points[i].localScale.x);
|
i++; DebugX.Draw(GetColor(Points[i])).BillboardCross(Points[i].position, Points[i].localScale.x);
|
||||||
i++; DebugX.Draw(GetColor(Points[i])).BillboardCircle(Points[i].position, Points[i].localScale.x * RADIUS_M);
|
i++; DebugX.Draw(GetColor(Points[i])).BillboardCircle(Points[i].position, Points[i].localScale.x * RADIUS_M);
|
||||||
i++; DebugX.Draw(GetColor(Points[i])).WireMesh<SphereMesh>(Points[i].position, Points[i].rotation, Points[i].localScale * RADIUS_M);
|
i++; DebugX.Draw(GetColor(Points[i])).WireMesh<SphereMesh>(Points[i].position, Points[i].rotation, Points[i].localScale * RADIUS_M);
|
||||||
i++; DebugX.Draw(GetColor(Points[i])).Text(Points[i].position, Points[i].name, DebugXTextSettings.WorldSpaceScale.SetSize(26).SetBackground(TextBackgroundColor));
|
i++; DebugX.Draw(GetColor(Points[i])).Text(Points[i].position, Points[i].name, DebugXTextSettings.WorldSpaceScale.SetSize(26).SetBackground(TextBackgroundColor));
|
||||||
@ -42,12 +43,7 @@ namespace DCFApixels.DebugXCore.Samples
|
|||||||
}
|
}
|
||||||
private Color GetColor(Transform pos1)
|
private Color GetColor(Transform pos1)
|
||||||
{
|
{
|
||||||
Vector3 pos = pos1.localPosition;
|
return Gradient.Evaluate(pos1, GradientMultiplier);
|
||||||
pos /= GradientMultiplier == 0 ? 1 : GradientMultiplier;
|
|
||||||
pos += Vector3.one * 0.5f;
|
|
||||||
float t = pos.x + pos.y + pos.z;
|
|
||||||
t /= 3f;
|
|
||||||
return Gradient.Evaluate(Mathf.Clamp01(t));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,3 +1,4 @@
|
|||||||
|
using DCFApixels.DebugXCore.Samples.Internal;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace DCFApixels.DebugXCore.Samples
|
namespace DCFApixels.DebugXCore.Samples
|
||||||
@ -43,12 +44,7 @@ namespace DCFApixels.DebugXCore.Samples
|
|||||||
}
|
}
|
||||||
private Color GetColor(Transform pos1)
|
private Color GetColor(Transform pos1)
|
||||||
{
|
{
|
||||||
Vector3 pos = pos1.localPosition;
|
return Gradient.Evaluate(pos1, GradientMultiplier);
|
||||||
pos /= GradientMultiplier == 0 ? 1 : GradientMultiplier;
|
|
||||||
pos += Vector3.one * 0.5f;
|
|
||||||
float t = pos.x + pos.y + pos.z;
|
|
||||||
t /= 3f;
|
|
||||||
return Gradient.Evaluate(Mathf.Clamp01(t));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
using DCFApixels.DebugXCore.Samples.Internal;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace DCFApixels.DebugXCore.Samples
|
namespace DCFApixels.DebugXCore.Samples
|
||||||
@ -44,12 +45,7 @@ namespace DCFApixels.DebugXCore.Samples
|
|||||||
}
|
}
|
||||||
private Color GetColor(Transform pos1)
|
private Color GetColor(Transform pos1)
|
||||||
{
|
{
|
||||||
Vector3 pos = pos1.localPosition;
|
return Gradient.Evaluate(pos1, GradientMultiplier);
|
||||||
pos /= GradientMultiplier == 0 ? 1 : GradientMultiplier;
|
|
||||||
pos += Vector3.one * 0.5f;
|
|
||||||
float t = pos.x + pos.y + pos.z;
|
|
||||||
t /= 3f;
|
|
||||||
return Gradient.Evaluate(Mathf.Clamp01(t));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
using DCFApixels.DebugXCore.Samples.Internal;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace DCFApixels.DebugXCore.Samples
|
namespace DCFApixels.DebugXCore.Samples
|
||||||
@ -8,6 +9,8 @@ namespace DCFApixels.DebugXCore.Samples
|
|||||||
public Gradient Gradient;
|
public Gradient Gradient;
|
||||||
public float GradientMultiplier = 5;
|
public float GradientMultiplier = 5;
|
||||||
public Transform[] Points;
|
public Transform[] Points;
|
||||||
|
public Transform WarrningPoint;
|
||||||
|
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
private void OnDrawGizmos()
|
private void OnDrawGizmos()
|
||||||
@ -50,18 +53,13 @@ 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);
|
||||||
|
#else
|
||||||
|
DebugX.Draw(GetColor(WarrningPoint).Inverse()).Text(WarrningPoint.position, "Add \"DEBUGX_ENABLE_PHYSICS2D\" define", DebugXTextSettings.WorldSpaceScale.SetSize(22).SetAnchor(TextAnchor.MiddleCenter));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
private Color GetColor(Transform pos1)
|
private Color GetColor(Transform pos1)
|
||||||
{
|
{
|
||||||
Vector3 pos = pos1.localPosition;
|
return Gradient.Evaluate(pos1, GradientMultiplier);
|
||||||
pos /= GradientMultiplier == 0 ? 1 : GradientMultiplier;
|
|
||||||
pos += Vector3.one * 0.5f;
|
|
||||||
//float t = pos.x + pos.y + pos.z;
|
|
||||||
//t /= 3f;
|
|
||||||
float t = pos.x + pos.z;
|
|
||||||
t /= 2f;
|
|
||||||
return Gradient.Evaluate(Mathf.Clamp01(t));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
using DCFApixels.DebugXCore.Samples.Internal;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace DCFApixels.DebugXCore.Samples
|
namespace DCFApixels.DebugXCore.Samples
|
||||||
@ -8,7 +9,7 @@ namespace DCFApixels.DebugXCore.Samples
|
|||||||
public Gradient Gradient;
|
public Gradient Gradient;
|
||||||
public float GradientMultiplier = 5;
|
public float GradientMultiplier = 5;
|
||||||
public Transform[] Points;
|
public Transform[] Points;
|
||||||
|
public Transform WarrningPoint;
|
||||||
|
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
@ -54,16 +55,13 @@ 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);
|
||||||
|
#else
|
||||||
|
DebugX.Draw(GetColor(WarrningPoint).Inverse()).Text(WarrningPoint.position, "Add \"DEBUGX_ENABLE_PHYSICS3D\" define", DebugXTextSettings.WorldSpaceScale.SetSize(22).SetAnchor(TextAnchor.MiddleCenter));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
private Color GetColor(Transform pos1)
|
private Color GetColor(Transform pos1)
|
||||||
{
|
{
|
||||||
Vector3 pos = pos1.localPosition;
|
return Gradient.Evaluate(pos1, GradientMultiplier);
|
||||||
pos /= GradientMultiplier == 0 ? 1 : GradientMultiplier;
|
|
||||||
pos += Vector3.one * 0.5f;
|
|
||||||
float t = pos.x + pos.y + pos.z;
|
|
||||||
t /= 3f;
|
|
||||||
return Gradient.Evaluate(Mathf.Clamp01(t));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
33
Samples/Scripts/Utils.cs
Normal file
33
Samples/Scripts/Utils.cs
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace DCFApixels.DebugXCore.Samples.Internal
|
||||||
|
{
|
||||||
|
internal static class Utils
|
||||||
|
{
|
||||||
|
public static Color Evaluate(this Gradient gradient, Transform transform, float m)
|
||||||
|
{
|
||||||
|
Vector3 pos = transform.localPosition;
|
||||||
|
pos /= m == 0 ? 1 : m;
|
||||||
|
pos += Vector3.one * 0.5f;
|
||||||
|
float t = pos.x + pos.z;
|
||||||
|
t /= 2f;
|
||||||
|
return gradient.Evaluate(Mathf.Clamp01(t));
|
||||||
|
}
|
||||||
|
public static Color Evaluate(this Gradient gradient, Transform transform0, Transform transform1, float m)
|
||||||
|
{
|
||||||
|
Vector3 pos = (transform0.localPosition + transform1.localPosition) * 0.5f;
|
||||||
|
pos /= m == 0 ? 1 : m;
|
||||||
|
pos += Vector3.one * 0.5f;
|
||||||
|
float t = pos.x + pos.z;
|
||||||
|
t /= 3f;
|
||||||
|
return gradient.Evaluate(Mathf.Clamp01(t));
|
||||||
|
}
|
||||||
|
public static Color Inverse(this Color c)
|
||||||
|
{
|
||||||
|
var a = c.a;
|
||||||
|
c = Color.white - c;
|
||||||
|
c.a = a;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
2
Samples/Scripts/Utils.cs.meta
Normal file
2
Samples/Scripts/Utils.cs.meta
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 646aedc98b9a6f3458a27f6d43e85990
|
@ -8,7 +8,7 @@
|
|||||||
"displayName": "DebugX",
|
"displayName": "DebugX",
|
||||||
"description": "",
|
"description": "",
|
||||||
"unity": "2021.3",
|
"unity": "2021.3",
|
||||||
"version": "0.8.11",
|
"version": "0.8.12",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/DCFApixels/DebugX.git"
|
"url": "https://github.com/DCFApixels/DebugX.git"
|
||||||
|
Loading…
Reference in New Issue
Block a user