mirror of
https://github.com/DCFApixels/Unity-DebugX.git
synced 2025-09-18 18:14:36 +08:00
Compare commits
No commits in common. "e470b229bc95be1f4abe7d6b95f1c8b37247862d" and "e4cd108ad9e1a3c86c813368b5a6d66e442b139b" have entirely different histories.
e470b229bc
...
e4cd108ad9
@ -27,11 +27,9 @@ 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);
|
||||||
@ -55,23 +53,6 @@ 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);
|
||||||
@ -90,18 +71,72 @@ namespace DCFApixels.DebugXCore.Internal
|
|||||||
}
|
}
|
||||||
GUILayout.EndVertical();
|
GUILayout.EndVertical();
|
||||||
|
|
||||||
GUILayout.EndScrollView();
|
// 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawReadonlyLeftToggle(string text, bool value)
|
if (GUILayout.Button("Clear All Gizmos"))
|
||||||
{
|
{
|
||||||
GUILayout.BeginHorizontal();
|
DebugX.ClearAllGizmos();
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,15 +64,11 @@ 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-модуля, достаточно добавить [в PackageManager](https://docs.unity3d.com/2023.2/Documentation/Manual/upm-ui-giturl.html) этот Git-URL :
|
Поддерживается установка в виде Unity-модуля, достаточно скопировать Git-URL [в PackageManager](https://docs.unity3d.com/2023.2/Documentation/Manual/upm-ui-giturl.html) или в `Packages/manifest.json`. Скопируйте этот 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,15 +63,10 @@ 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):
|
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:
|
||||||
```
|
```
|
||||||
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,7 +4,6 @@ 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,18 +198,10 @@ 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
|
||||||
@ -229,10 +221,8 @@ 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
|
#region Mesh //TODO потестить
|
||||||
[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.CheckQuaternionOrDefault();
|
Rotation = rotation;
|
||||||
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.CheckQuaternionOrDefault();
|
Rotation = rotation;
|
||||||
Position = position;
|
Position = position;
|
||||||
Size = size;
|
Size = size;
|
||||||
}
|
}
|
||||||
|
@ -1,64 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,2 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: c3f0e370bd83bef4a8955d9f9979ce01
|
|
@ -12,40 +12,16 @@ namespace DCFApixels
|
|||||||
public readonly partial struct DrawHandler
|
public readonly partial struct DrawHandler
|
||||||
{
|
{
|
||||||
#region BillboardCircle
|
#region BillboardCircle
|
||||||
[IN(LINE)]
|
[IN(LINE)] public DrawHandler BillboardCircle(Vector3 position, float radius) => Mesh<CircleMesh, BillboardMat>(position, Quaternion.identity, new Vector3(radius, radius, radius));
|
||||||
public DrawHandler BillboardCircle(Vector3 position, float radius)
|
|
||||||
{
|
|
||||||
return Mesh<CircleMesh, BillboardMat>(position, Quaternion.identity, new Vector3(radius, radius, radius));
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region BillboardCross
|
#region Cross
|
||||||
[IN(LINE)]
|
[IN(LINE)] public DrawHandler Cross(Vector3 position, float size) => Mesh<DotCrossMesh, BillboardMat>(position, Quaternion.identity, new Vector3(size, size, size));
|
||||||
[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)]
|
[IN(LINE)] public DrawHandler Sphere(Vector3 position, float radius) => Mesh<SphereMesh, LitMat>(position, Quaternion.identity, new Vector3(radius, radius, radius));
|
||||||
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
|
||||||
@ -131,30 +107,9 @@ namespace DCFApixels
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
#region Circle
|
#region Circle
|
||||||
[IN(LINE)]
|
[IN(LINE)] public DrawHandler Circle(Vector3 position, Vector3 normal, float radius) => Mesh<CircleMesh, LitMat>(position, Quaternion.LookRotation(normal), new Vector3(radius, radius, radius));
|
||||||
public DrawHandler Circle<TMat>(Vector3 position, Vector3 normal, float radius)
|
[IN(LINE)] public DrawHandler Circle(Vector3 position, Quaternion rotation, float radius) => Mesh<CircleMesh, LitMat>(position, rotation, new Vector3(radius, radius, 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
|
||||||
@ -165,15 +120,10 @@ 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)
|
||||||
{
|
{
|
||||||
return Mesh<CylinderMesh>(position, rotation * Quaternion.Euler(-90, 0, 0), new Vector3(radius * 2f, radius * 2f, height));
|
Mesh<CylinderMesh, LitMat>(position, rotation * Quaternion.Euler(-90, 0, 0), new Vector3(radius * 2f, radius * 2f, height));
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -219,18 +169,12 @@ 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)
|
||||||
{
|
{
|
||||||
return Mesh<ConeMesh>(position, rotation * Quaternion.Euler(-90, 0, 0), new Vector3(radius * 2f, radius * 2f, height));
|
Mesh<ConeMesh, LitMat>(position, rotation * Quaternion.Euler(-90, 0, 0), new Vector3(radius * 2f, radius * 2f, height));
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -271,18 +215,12 @@ 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)
|
||||||
{
|
{
|
||||||
return Mesh<TriangleMesh>(position, rotation, new Vector3(size.x, size.y, 1f));
|
Mesh<TriangleMesh, LitMat>(position, rotation, new Vector3(size.x, size.y, 1f));
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -298,8 +236,7 @@ namespace DCFApixels
|
|||||||
|
|
||||||
#region Capsule
|
#region Capsule
|
||||||
[IN(LINE)]
|
[IN(LINE)]
|
||||||
public DrawHandler Capsule<TMat>(Vector3 position, Quaternion rotation, float radius, float height)
|
public DrawHandler Capsule(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;
|
||||||
@ -307,16 +244,11 @@ namespace DCFApixels
|
|||||||
var halfHeigth = height * 0.5f;
|
var halfHeigth = height * 0.5f;
|
||||||
var normal = rotation * Vector3.up;
|
var normal = rotation * Vector3.up;
|
||||||
|
|
||||||
Mesh<CapsuleHeadMesh, TMat>(position + normal * halfHeigth, rotation, new Vector3(radius, radius, radius));
|
Mesh<CapsuleHeadMesh, LitMat>(position + normal * halfHeigth, rotation, new Vector3(radius, radius, radius));
|
||||||
Mesh<CapsuleBodyMesh, TMat>(position, rotation, new Vector3(radius, height, radius));
|
Mesh<CapsuleBodyMesh, LitMat>(position, rotation, new Vector3(radius, height, radius));
|
||||||
Mesh<CapsuleHeadMesh, TMat>(position - normal * halfHeigth, rotation * Quaternion.Euler(0, 0, 180), new Vector3(radius, radius, radius));
|
Mesh<CapsuleHeadMesh, LitMat>(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
|
||||||
@ -348,11 +280,9 @@ namespace DCFApixels
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
#region FlatCapsule
|
#region FlatCapsule
|
||||||
[IN(LINE)]
|
[IN(LINE)]
|
||||||
public DrawHandler FlatCapsule<TMat>(Vector3 position, Quaternion rotation, float radius, float height)
|
public DrawHandler FlatCapsule(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;
|
||||||
@ -360,16 +290,11 @@ namespace DCFApixels
|
|||||||
var halfHeigth = height * 0.5f;
|
var halfHeigth = height * 0.5f;
|
||||||
var normal = rotation * Vector3.up;
|
var normal = rotation * Vector3.up;
|
||||||
|
|
||||||
Mesh<FlatCapsuleHeadMesh, TMat>(position + normal * halfHeigth, rotation, new Vector3(radius, radius, radius));
|
Mesh<FlatCapsuleHeadMesh, LitMat>(position + normal * halfHeigth, rotation, new Vector3(radius, radius, radius));
|
||||||
Mesh<FlatCapsuleBodyMesh, TMat>(position, rotation, new Vector3(radius, height, radius));
|
Mesh<FlatCapsuleBodyMesh, LitMat>(position, rotation, new Vector3(radius, height, radius));
|
||||||
Mesh<FlatCapsuleHeadMesh, TMat>(position - normal * halfHeigth, rotation * Quaternion.Euler(0, 0, 180), new Vector3(radius, radius, radius));
|
Mesh<FlatCapsuleHeadMesh, LitMat>(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
|
||||||
@ -411,28 +336,8 @@ 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)]
|
[IN(LINE)] public DrawHandler Cube(Vector3 position, Quaternion rotation, float size) => Mesh<CubeMesh, LitMat>(position, rotation, new Vector3(size, size, size));
|
||||||
public DrawHandler Cube<TMat>(Vector3 position, Quaternion rotation, float size)
|
[IN(LINE)] public DrawHandler Cube(Vector3 position, Quaternion rotation, Vector3 size) => Mesh<CubeMesh, LitMat>(position, rotation, 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
|
||||||
@ -553,32 +458,11 @@ 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)]
|
[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
|
||||||
public DrawHandler Quad<TMat>(Vector3 position, Quaternion rotation, float size)
|
[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
|
||||||
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,7 +11,6 @@ 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)
|
||||||
@ -131,7 +130,6 @@ 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,10 +9,5 @@ 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,7 +31,6 @@ 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
|
||||||
@ -40,14 +39,7 @@ Shader "DCFApixels/DebugX/Handles"
|
|||||||
float4 color;
|
float4 color;
|
||||||
};
|
};
|
||||||
StructuredBuffer<InstanceData> _DataBuffer;
|
StructuredBuffer<InstanceData> _DataBuffer;
|
||||||
void setup()
|
|
||||||
{
|
|
||||||
InstanceData data = _DataBuffer[unity_InstanceID];
|
|
||||||
UNITY_MATRIX_M = data.m; //UNITY_MATRIX_M
|
|
||||||
_Color = data.color;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct appdata_t
|
struct appdata_t
|
||||||
{
|
{
|
||||||
float4 vertex : POSITION;
|
float4 vertex : POSITION;
|
||||||
@ -66,14 +58,55 @@ 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));
|
||||||
|
@ -1,47 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 728ffe8b3d2321e45a960a3a90e65bc6
|
|
||||||
ShaderIncludeImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@ -33,7 +33,6 @@ 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
|
||||||
@ -42,14 +41,7 @@ Shader "DCFApixels/DebugX/Handles Overwrite"
|
|||||||
float4 color;
|
float4 color;
|
||||||
};
|
};
|
||||||
StructuredBuffer<InstanceData> _DataBuffer;
|
StructuredBuffer<InstanceData> _DataBuffer;
|
||||||
void setup()
|
|
||||||
{
|
|
||||||
InstanceData data = _DataBuffer[unity_InstanceID];
|
|
||||||
UNITY_MATRIX_M = data.m; //UNITY_MATRIX_M
|
|
||||||
_Color = data.color;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct appdata_t
|
struct appdata_t
|
||||||
{
|
{
|
||||||
float4 vertex : POSITION;
|
float4 vertex : POSITION;
|
||||||
@ -68,13 +60,54 @@ 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,7 +32,6 @@ 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
|
||||||
@ -41,15 +40,7 @@ Shader "DCFApixels/DebugX/Handles Wire"
|
|||||||
float4 color;
|
float4 color;
|
||||||
};
|
};
|
||||||
StructuredBuffer<InstanceData> _DataBuffer;
|
StructuredBuffer<InstanceData> _DataBuffer;
|
||||||
void setup()
|
|
||||||
{
|
|
||||||
InstanceData data = _DataBuffer[unity_InstanceID];
|
|
||||||
UNITY_MATRIX_M = data.m; //UNITY_MATRIX_M
|
|
||||||
_Color = data.color;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
struct appdata_t
|
struct appdata_t
|
||||||
{
|
{
|
||||||
float4 vertex : POSITION;
|
float4 vertex : POSITION;
|
||||||
@ -73,14 +64,54 @@ 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));
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,2 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: cfcf280d995044a46b559a8da9d2f25d
|
|
@ -54,9 +54,7 @@ Shader "DCFApixels/DebugX/Samples/FakeLighth"
|
|||||||
|
|
||||||
fixed4 frag (v2f i) : SV_Target
|
fixed4 frag (v2f i) : SV_Target
|
||||||
{
|
{
|
||||||
float m = (1.0 - Unity_PolarCoordinates_float(i.uv, float2(0.5, 0.5), 1, 1).r);
|
return _Color * (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: 3
|
GradientMultiplier: 2
|
||||||
Points:
|
Points:
|
||||||
- {fileID: 1728437382}
|
- {fileID: 1728437382}
|
||||||
- {fileID: 54381892}
|
- {fileID: 54381892}
|
||||||
@ -875,37 +875,6 @@ 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
|
||||||
@ -1006,7 +975,6 @@ 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
|
||||||
@ -1128,7 +1096,6 @@ 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
|
||||||
@ -1654,7 +1621,7 @@ MonoBehaviour:
|
|||||||
m_ColorSpace: -1
|
m_ColorSpace: -1
|
||||||
m_NumColorKeys: 3
|
m_NumColorKeys: 3
|
||||||
m_NumAlphaKeys: 2
|
m_NumAlphaKeys: 2
|
||||||
GradientMultiplier: 1.5
|
GradientMultiplier: 2
|
||||||
WidthMultiplier: 1
|
WidthMultiplier: 1
|
||||||
StartLines:
|
StartLines:
|
||||||
- {fileID: 1105319542}
|
- {fileID: 1105319542}
|
||||||
@ -2539,7 +2506,6 @@ 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
|
||||||
@ -3684,37 +3650,6 @@ 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
|
||||||
@ -5579,7 +5514,7 @@ MonoBehaviour:
|
|||||||
m_ColorSpace: -1
|
m_ColorSpace: -1
|
||||||
m_NumColorKeys: 3
|
m_NumColorKeys: 3
|
||||||
m_NumAlphaKeys: 2
|
m_NumAlphaKeys: 2
|
||||||
GradientMultiplier: 3
|
GradientMultiplier: 2
|
||||||
Points:
|
Points:
|
||||||
- {fileID: 1170244042}
|
- {fileID: 1170244042}
|
||||||
- {fileID: 151432312}
|
- {fileID: 151432312}
|
||||||
@ -5792,7 +5727,6 @@ 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,4 +1,3 @@
|
|||||||
using DCFApixels.DebugXCore.Samples.Internal;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace DCFApixels.DebugXCore.Samples
|
namespace DCFApixels.DebugXCore.Samples
|
||||||
@ -40,7 +39,12 @@ namespace DCFApixels.DebugXCore.Samples
|
|||||||
}
|
}
|
||||||
private Color GetColor(Transform pos1, Transform pos2)
|
private Color GetColor(Transform pos1, Transform pos2)
|
||||||
{
|
{
|
||||||
return Gradient.Evaluate(pos1, pos2, GradientMultiplier);
|
Vector3 pos = (pos1.localPosition + pos2.localPosition) * 0.5f;
|
||||||
|
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,4 +1,3 @@
|
|||||||
using DCFApixels.DebugXCore.Samples.Internal;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace DCFApixels.DebugXCore.Samples
|
namespace DCFApixels.DebugXCore.Samples
|
||||||
@ -27,7 +26,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])).BillboardCross(Points[i].position, Points[i].localScale.x);
|
i++; DebugX.Draw(GetColor(Points[i])).Cross(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));
|
||||||
@ -43,7 +42,12 @@ namespace DCFApixels.DebugXCore.Samples
|
|||||||
}
|
}
|
||||||
private Color GetColor(Transform pos1)
|
private Color GetColor(Transform pos1)
|
||||||
{
|
{
|
||||||
return Gradient.Evaluate(pos1, GradientMultiplier);
|
Vector3 pos = pos1.localPosition;
|
||||||
|
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,4 +1,3 @@
|
|||||||
using DCFApixels.DebugXCore.Samples.Internal;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace DCFApixels.DebugXCore.Samples
|
namespace DCFApixels.DebugXCore.Samples
|
||||||
@ -44,7 +43,12 @@ namespace DCFApixels.DebugXCore.Samples
|
|||||||
}
|
}
|
||||||
private Color GetColor(Transform pos1)
|
private Color GetColor(Transform pos1)
|
||||||
{
|
{
|
||||||
return Gradient.Evaluate(pos1, GradientMultiplier);
|
Vector3 pos = pos1.localPosition;
|
||||||
|
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,4 +1,3 @@
|
|||||||
using DCFApixels.DebugXCore.Samples.Internal;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace DCFApixels.DebugXCore.Samples
|
namespace DCFApixels.DebugXCore.Samples
|
||||||
@ -45,7 +44,12 @@ namespace DCFApixels.DebugXCore.Samples
|
|||||||
}
|
}
|
||||||
private Color GetColor(Transform pos1)
|
private Color GetColor(Transform pos1)
|
||||||
{
|
{
|
||||||
return Gradient.Evaluate(pos1, GradientMultiplier);
|
Vector3 pos = pos1.localPosition;
|
||||||
|
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,4 +1,3 @@
|
|||||||
using DCFApixels.DebugXCore.Samples.Internal;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace DCFApixels.DebugXCore.Samples
|
namespace DCFApixels.DebugXCore.Samples
|
||||||
@ -9,8 +8,6 @@ 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()
|
||||||
@ -53,13 +50,18 @@ 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)
|
||||||
{
|
{
|
||||||
return Gradient.Evaluate(pos1, GradientMultiplier);
|
Vector3 pos = pos1.localPosition;
|
||||||
|
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,4 +1,3 @@
|
|||||||
using DCFApixels.DebugXCore.Samples.Internal;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace DCFApixels.DebugXCore.Samples
|
namespace DCFApixels.DebugXCore.Samples
|
||||||
@ -9,7 +8,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
|
||||||
@ -55,13 +54,16 @@ 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)
|
||||||
{
|
{
|
||||||
return Gradient.Evaluate(pos1, GradientMultiplier);
|
Vector3 pos = pos1.localPosition;
|
||||||
|
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,33 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,2 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 646aedc98b9a6f3458a27f6d43e85990
|
|
@ -8,7 +8,7 @@
|
|||||||
"displayName": "DebugX",
|
"displayName": "DebugX",
|
||||||
"description": "",
|
"description": "",
|
||||||
"unity": "2021.3",
|
"unity": "2021.3",
|
||||||
"version": "0.8.12",
|
"version": "0.8.11",
|
||||||
"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