mirror of
https://github.com/DCFApixels/Unity-DebugX.git
synced 2025-09-17 17:34:35 +08:00
update
This commit is contained in:
parent
1d2f9fd700
commit
339369bc73
@ -12,6 +12,7 @@ using UnityEngine.LowLevel;
|
||||
using UnityEngine.PlayerLoop;
|
||||
using Unity.Collections.LowLevel.Unsafe;
|
||||
using DCFApixels.DebugXCore.Internal;
|
||||
using static DCFApixels.DebugXCore.DebugXUtility;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
@ -4,6 +4,7 @@ using Unity.Collections.LowLevel.Unsafe;
|
||||
using Unity.Jobs;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using static DCFApixels.DebugXCore.DebugXUtility;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
@ -2,6 +2,7 @@
|
||||
using DCFApixels.DebugXCore;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using static DCFApixels.DebugXCore.DebugXUtility;
|
||||
|
||||
namespace DCFApixels
|
||||
{
|
||||
|
@ -3,6 +3,7 @@ using DCFApixels.DebugXCore;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using static DCFApixels.DebugXCore.DebugXUtility;
|
||||
|
||||
namespace DCFApixels
|
||||
{
|
||||
|
@ -1,5 +1,4 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace DCFApixels
|
||||
{
|
||||
|
@ -3,15 +3,12 @@
|
||||
#if DEBUG
|
||||
#define DEV_MODE
|
||||
#endif
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System;
|
||||
using Unity.Collections.LowLevel.Unsafe;
|
||||
using System.Buffers;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
|
||||
namespace DCFApixels
|
||||
{
|
||||
@ -19,96 +16,6 @@ namespace DCFApixels
|
||||
|
||||
public static unsafe partial class DebugX
|
||||
{
|
||||
#region Utils Methods
|
||||
private static string GetGenericTypeName_Internal(Type type, int maxDepth, bool isFull)
|
||||
{
|
||||
#if (DEBUG && !DISABLE_DEBUG) || !REFLECTION_DISABLED //â äåáàæíûõ óòèëèòàõ REFLECTION_DISABLED òîëüêî â ðåëèçíîì áèëäå ðàáîòàåò
|
||||
string typeName = isFull ? type.FullName : type.Name;
|
||||
if (!type.IsGenericType || maxDepth == 0)
|
||||
{
|
||||
return typeName;
|
||||
}
|
||||
int genericInfoIndex = typeName.LastIndexOf('`');
|
||||
if (genericInfoIndex > 0)
|
||||
{
|
||||
typeName = typeName.Remove(genericInfoIndex);
|
||||
}
|
||||
|
||||
string genericParams = "";
|
||||
Type[] typeParameters = type.GetGenericArguments();
|
||||
for (int i = 0; i < typeParameters.Length; ++i)
|
||||
{
|
||||
//÷òîáû ñòðîêà íå áûëà ñëèøêîì äëèííîé, èñïîëüçóþòñÿ ñîêðàùåííûå èìåíà äëÿ òèïîâ àðãóìåíòîâ
|
||||
string paramTypeName = GetGenericTypeName_Internal(typeParameters[i], maxDepth - 1, false);
|
||||
genericParams += (i == 0 ? paramTypeName : $", {paramTypeName}");
|
||||
}
|
||||
return $"{typeName}<{genericParams}>";
|
||||
#else
|
||||
Debug.LogWarning($"Reflection is not available, the {nameof(GetGenericTypeName_Internal)} method does not work.");
|
||||
return isFull ? type.FullName : type.Name;
|
||||
#endif
|
||||
}
|
||||
|
||||
[IN(LINE)]
|
||||
public static float FastMagnitude(Vector3 v)
|
||||
{
|
||||
return FastSqrt(v.x * v.x + v.y * v.y + v.z * v.z);
|
||||
}
|
||||
[IN(LINE)]
|
||||
private static unsafe float FastSqrt(float number)
|
||||
{
|
||||
long i;
|
||||
float x2, y;
|
||||
const float threehalfs = 1.5F;
|
||||
|
||||
x2 = number * 0.5F;
|
||||
y = number;
|
||||
i = *(long*)&y; // evil floating point bit level hacking
|
||||
i = 0x5f3759df - (i >> 1); // what the fuck?
|
||||
y = *(float*)&i;
|
||||
y = y * (threehalfs - (x2 * y * y)); // 1st iteration
|
||||
//y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed
|
||||
|
||||
return 1 / y;
|
||||
}
|
||||
[IN(LINE)]
|
||||
private static int NextPow2(int v)
|
||||
{
|
||||
v--;
|
||||
v |= v >> 1;
|
||||
v |= v >> 2;
|
||||
v |= v >> 4;
|
||||
v |= v >> 8;
|
||||
v |= v >> 16;
|
||||
return ++v;
|
||||
}
|
||||
private static Color[] _setColorBuffer = new Color[64];
|
||||
[IN(LINE)]
|
||||
static void AddColorsToMesh(Mesh mesh, Color color)
|
||||
{
|
||||
int vertexCount = mesh.vertexCount;
|
||||
if (_setColorBuffer.Length < vertexCount)
|
||||
{
|
||||
_setColorBuffer = new Color[NextPow2(vertexCount)];
|
||||
}
|
||||
for (int i = 0; i < mesh.vertexCount; i++)
|
||||
{
|
||||
_setColorBuffer[i] = color;
|
||||
}
|
||||
mesh.SetColors(_setColorBuffer, 0, vertexCount);
|
||||
}
|
||||
|
||||
[IN(LINE)]
|
||||
private static bool IsGizmosRender()
|
||||
{
|
||||
bool result = true;
|
||||
#if UNITY_EDITOR
|
||||
result = Handles.ShouldRenderGizmos();
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region private StructList
|
||||
private interface IStructListElement<T>
|
||||
{
|
||||
|
85
Runtime/Utils/DebugXUtility.cs
Normal file
85
Runtime/Utils/DebugXUtility.cs
Normal file
@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using static DCFApixels.DebugX;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
namespace DCFApixels.DebugXCore
|
||||
{
|
||||
using IN = System.Runtime.CompilerServices.MethodImplAttribute;
|
||||
public static class DebugXUtility
|
||||
{
|
||||
public static string GetGenericTypeName_Internal(Type type, int maxDepth, bool isFull)
|
||||
{
|
||||
#if DEBUG || !REFLECTION_DISABLED //в дебажных утилитах REFLECTION_DISABLED только в релизном билде работает
|
||||
string typeName = isFull ? type.FullName : type.Name;
|
||||
if (!type.IsGenericType || maxDepth == 0)
|
||||
{
|
||||
return typeName;
|
||||
}
|
||||
int genericInfoIndex = typeName.LastIndexOf('`');
|
||||
if (genericInfoIndex > 0)
|
||||
{
|
||||
typeName = typeName.Remove(genericInfoIndex);
|
||||
}
|
||||
|
||||
string genericParams = "";
|
||||
Type[] typeParameters = type.GetGenericArguments();
|
||||
for (int i = 0; i < typeParameters.Length; ++i)
|
||||
{
|
||||
//чтобы строка не была слишком длинной, используются сокращенные имена для типов аргументов
|
||||
string paramTypeName = GetGenericTypeName_Internal(typeParameters[i], maxDepth - 1, false);
|
||||
genericParams += (i == 0 ? paramTypeName : $", {paramTypeName}");
|
||||
}
|
||||
return $"{typeName}<{genericParams}>";
|
||||
#else
|
||||
Debug.LogWarning($"Reflection is not available, the {nameof(GetGenericTypeName_Internal)} method does not work.");
|
||||
return isFull ? type.FullName : type.Name;
|
||||
#endif
|
||||
}
|
||||
|
||||
[IN(LINE)]
|
||||
public static float FastMagnitude(Vector3 v)
|
||||
{
|
||||
return FastSqrt(v.x * v.x + v.y * v.y + v.z * v.z);
|
||||
}
|
||||
[IN(LINE)]
|
||||
public static unsafe float FastSqrt(float number)
|
||||
{
|
||||
long i;
|
||||
float x2, y;
|
||||
const float threehalfs = 1.5F;
|
||||
|
||||
x2 = number * 0.5F;
|
||||
y = number;
|
||||
i = *(long*)&y; // evil floating point bit level hacking
|
||||
i = 0x5f3759df - (i >> 1); // what the fuck?
|
||||
y = *(float*)&i;
|
||||
y = y * (threehalfs - (x2 * y * y)); // 1st iteration
|
||||
//y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed
|
||||
|
||||
return 1 / y;
|
||||
}
|
||||
[IN(LINE)]
|
||||
public static int NextPow2(int v)
|
||||
{
|
||||
v--;
|
||||
v |= v >> 1;
|
||||
v |= v >> 2;
|
||||
v |= v >> 4;
|
||||
v |= v >> 8;
|
||||
v |= v >> 16;
|
||||
return ++v;
|
||||
}
|
||||
[IN(LINE)]
|
||||
public static bool IsGizmosRender()
|
||||
{
|
||||
bool result = true;
|
||||
#if UNITY_EDITOR
|
||||
result = Handles.ShouldRenderGizmos();
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
2
Runtime/Utils/DebugXUtility.cs.meta
Normal file
2
Runtime/Utils/DebugXUtility.cs.meta
Normal file
@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b2f02e57e5eea164aabe0c86b83f1b70
|
@ -54,6 +54,6 @@ Material:
|
||||
- _QueueControl: 0
|
||||
- _QueueOffset: 0
|
||||
m_Colors:
|
||||
- _Color: {r: 0, g: 0.06882353, b: 0.09, a: 1}
|
||||
- _Color: {r: 0, g: 0.071999975, b: 0.09, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
m_AllowLocking: 1
|
||||
|
@ -1,6 +1,6 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace DCFApixels
|
||||
namespace DCFApixels.DebugXCore.Samples
|
||||
{
|
||||
[SelectionBase]
|
||||
public class DebugXSample_Lines : MonoBehaviour
|
||||
|
@ -1,7 +1,6 @@
|
||||
using DCFApixels.DebugXCore;
|
||||
using UnityEngine;
|
||||
|
||||
namespace DCFApixels
|
||||
namespace DCFApixels.DebugXCore.Samples
|
||||
{
|
||||
[SelectionBase]
|
||||
public class DebugXSample_Other : MonoBehaviour
|
||||
|
@ -1,6 +1,6 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace DCFApixels
|
||||
namespace DCFApixels.DebugXCore.Samples
|
||||
{
|
||||
[SelectionBase]
|
||||
public class DebugXSample_Primitives2D : MonoBehaviour
|
||||
|
@ -1,6 +1,6 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace DCFApixels
|
||||
namespace DCFApixels.DebugXCore.Samples
|
||||
{
|
||||
[SelectionBase]
|
||||
public class DebugXSample_Primitives3D : MonoBehaviour
|
||||
|
@ -1,6 +1,6 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace DCFApixels
|
||||
namespace DCFApixels.DebugXCore.Samples
|
||||
{
|
||||
[SelectionBase]
|
||||
public class DebugXSample_Raycasts2D : MonoBehaviour
|
||||
|
@ -1,6 +1,6 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace DCFApixels
|
||||
namespace DCFApixels.DebugXCore.Samples
|
||||
{
|
||||
[SelectionBase]
|
||||
public class DebugXSample_Raycasts3D : MonoBehaviour
|
||||
|
Loading…
Reference in New Issue
Block a user