Compare commits

..

No commits in common. "main" and "0.8.15" have entirely different histories.
main ... 0.8.15

17 changed files with 74 additions and 93 deletions

View File

@ -1,5 +1,4 @@
#pragma warning disable CS0162 // Обнаружен недостижимый код
#if UNITY_EDITOR
#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.Compilation;
using UnityEngine;
@ -13,26 +12,28 @@ namespace DCFApixels.DebugXCore.Internal
{
DebugXSettings window = (DebugXSettings)EditorWindow.GetWindow(typeof(DebugXSettings));
window.Show();
//window._isHasDisableDebugXInBuildSymbols = null;
CompilationPipeline.compilationFinished -= CompilationPipeline_compilationFinished;
CompilationPipeline.compilationFinished += CompilationPipeline_compilationFinished;
}
private static void CompilationPipeline_compilationFinished(object obj)
{
//_isCompilation = false;
_defines = null;
}
//private static bool _isCompilation;
//private bool? _isHasDisableDebugXInBuildSymbols = false;
//private const string DEFINE_NAME = nameof(DebugXDefines.DEBUGX_DISABLE_INBUILD);
private static (string name, bool flag)[] _defines = null;
private static Vector2 _pos;
private void OnGUI()
{
if (DebugXDefines.DISABLE_DEBUGX)
{
GUI.enabled = false;
}
_pos = GUILayout.BeginScrollView(_pos, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
float tmpFloat;
int tmpInt;
DebugX.GlobalTimeScale = EditorGUILayout.FloatField("TimeScale", DebugX.GlobalTimeScale);
EditorGUI.BeginChangeCheck();
@ -76,10 +77,7 @@ namespace DCFApixels.DebugXCore.Internal
{
DebugX.ClearAllGizmos();
}
if (DebugXDefines.DISABLE_DEBUGX)
{
GUI.enabled = true;
}
GUILayout.Space(4);
GUILayout.BeginVertical(EditorStyles.helpBox);

View File

@ -1,6 +1,5 @@
#if DISABLE_DEBUGX
#if DISABLE_DEBUG
#undef DEBUG
#undef UNITY_EDITOR
#endif
using System.Runtime.CompilerServices;
using UnityEngine;
@ -55,8 +54,8 @@ namespace DCFApixels.DebugXCore
{
public static class DebugXDefines
{
public const bool DISABLE_DEBUGX =
#if DISABLE_DEBUGX
public const bool DISABLE_DEBUG =
#if DISABLE_DEBUG
true;
#else
false;
@ -81,24 +80,3 @@ namespace DCFApixels.DebugXCore
#endif
}
}
// Example of DefineConstsType
// public static class SomeDefineConstsType
// {
// public const bool SOME_DEFINE_1 =
// #if SOME_DEFINE_1
// true;
// #else
// false;
// #endif
// public const bool SOME_DEFINE_2 =
// #if SOME_DEFINE_2
// true;
// #else
// false;
// #endif
// // ...
// }

View File

@ -1,6 +1,8 @@
#if DISABLE_DEBUGX
#if DISABLE_DEBUG
#undef DEBUG
#undef UNITY_EDITOR
#endif
#if DEBUG
#define DEV_MODE
#endif
#if UNITY_EDITOR
using UnityEditor;
@ -14,9 +16,9 @@ using UnityEngine.LowLevel;
using UnityEngine.PlayerLoop;
using Unity.Collections.LowLevel.Unsafe;
using DCFApixels.DebugXCore.Internal;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Buffers;
namespace DCFApixels
{
@ -44,26 +46,19 @@ namespace DCFApixels
{
var invocationList = eventToClean.GetInvocationList();
var buffer = ArrayPool<Delegate>.Shared.Rent(invocationList.Length);
var bufferCount = 0;
foreach (var invocation in invocationList)
{
if(!(invocation.Target is UnityEngine.Object targetObj) || targetObj != null)
{
buffer[bufferCount++] = invocation;
}
}
var validDelegates = invocationList
.Where(d => d.Target as UnityEngine.Object == null || d.Target as UnityEngine.Object != null)
.Where(d => !(d.Target is UnityEngine.Object targetObj) || targetObj != null)
.ToArray();
if (bufferCount != invocationList.Length)
if (validDelegates.Length != invocationList.Length)
{
eventToClean = null;
for (int i = 0; i < bufferCount; i++)
foreach (var delegateItem in validDelegates)
{
eventToClean += (OnDrawGizmoHandler)buffer[i];
eventToClean += (OnDrawGizmoHandler)delegateItem;
}
}
ArrayPool<Delegate>.Shared.Return(buffer);
}
internal static void CleanupOnDrawGizmo()
@ -90,7 +85,7 @@ namespace DCFApixels
private static ulong _timeTicks = 0;
#if UNITY_EDITOR
private static readonly Unity.Profiling.ProfilerMarker _onDrawGizmoCallback = new Unity.Profiling.ProfilerMarker($"{nameof(DebugX)}.{nameof(DebugXEvents.OnDrawGizmo)}");
private static readonly Unity.Profiling.ProfilerMarker _onDrawGizmoCalllback = new Unity.Profiling.ProfilerMarker($"{nameof(DebugX)}.{nameof(DebugXEvents.OnDrawGizmo)}");
#endif
public static ulong RenderTicks
@ -126,7 +121,6 @@ namespace DCFApixels
#region ctor
static DebugX()
{
#if UNITY_EDITOR || !DEBUGX_DISABLE_INBUILD
InitGlobals();
if (IsSRP)
@ -172,7 +166,7 @@ namespace DCFApixels
//Application.onBeforeRender -= Application_onBeforeRender;
//Application.onBeforeRender += Application_onBeforeRender;
#endif
#if UNITY_EDITOR
EditorApplication.pauseStateChanged -= EditorApplication_pauseStateChanged;
@ -377,7 +371,7 @@ namespace DCFApixels
if (DebugXUtility.IsGizmosRender())
{
#if UNITY_EDITOR
using (_onDrawGizmoCallback.Auto())
using (_onDrawGizmoCalllback.Auto())
#endif
{
DebugXEvents.InvokeOnDrawGizmo(camera);
@ -708,7 +702,7 @@ namespace DCFApixels
private readonly IGizmoRenderer_PostRender<T> _rendererUnityGizmos;
private readonly bool _isStatic;
#if DEBUG
#if DEV_MODE
private static readonly Unity.Profiling.ProfilerMarker _timerMarker = new Unity.Profiling.ProfilerMarker($"{DebugXUtility.GetGenericTypeName(typeof(T), 3, false)}.{nameof(UpdateTimer)}");
private static readonly Unity.Profiling.ProfilerMarker _prepareMarker = new Unity.Profiling.ProfilerMarker($"{DebugXUtility.GetGenericTypeName(typeof(T), 3, false)}.{nameof(Prepare)}");
private static readonly Unity.Profiling.ProfilerMarker _renderMarker = new Unity.Profiling.ProfilerMarker($"{DebugXUtility.GetGenericTypeName(typeof(T), 3, false)}.{nameof(Render)}");
@ -764,7 +758,7 @@ namespace DCFApixels
{
_staticCommandBuffer.Clear();
int removeCount = 0;
#if DEBUG
#if DEV_MODE
using (_timerMarker.Auto())
#endif
{
@ -787,7 +781,7 @@ namespace DCFApixels
public sealed override int RunEnd()
{
int removeCount = 0;
#if DEBUG
#if DEV_MODE
using (_timerMarker.Auto())
#endif
{
@ -820,7 +814,7 @@ namespace DCFApixels
public override void Prepare()
{
if (_gizmos.Count <= 0) { return; }
#if DEBUG
#if DEV_MODE
using (_prepareMarker.Auto())
#endif
{
@ -840,7 +834,7 @@ namespace DCFApixels
public override void Render(ICommandBufferExecutor cbExecutor)
{
if (_gizmos.Count <= 0) { return; }
#if DEBUG
#if DEV_MODE
using (_renderMarker.Auto())
#endif
{
@ -863,7 +857,7 @@ namespace DCFApixels
if (_rendererUnityGizmos == null) { return; }
//Debug.Log(_gizmos._count);
if (_gizmos.Count <= 0) { return; }
#if DEBUG
#if DEV_MODE
using (_renderMarker.Auto())
#endif
{

View File

@ -1,6 +1,5 @@
#if DISABLE_DEBUGX
#if DISABLE_DEBUG
#undef DEBUG
#undef UNITY_EDITOR
#endif
#if UNITY_EDITOR
using UnityEditor;

View File

@ -1,6 +1,5 @@
#if DISABLE_DEBUGX
#if DISABLE_DEBUG
#undef DEBUG
#undef UNITY_EDITOR
#endif
#if UNITY_EDITOR
using UnityEditor;

View File

@ -1,6 +1,5 @@
#if DISABLE_DEBUGX
#if DISABLE_DEBUG
#undef DEBUG
#undef UNITY_EDITOR
#endif
using DCFApixels.DebugXCore;
using UnityEngine;

View File

@ -1,6 +1,5 @@
#if DISABLE_DEBUGX
#if DISABLE_DEBUG
#undef DEBUG
#undef UNITY_EDITOR
#endif
using DCFApixels.DebugXCore;
using DCFApixels.DebugXCore.Internal;

View File

@ -1,6 +1,5 @@
#if DISABLE_DEBUGX
#if DISABLE_DEBUG
#undef DEBUG
#undef UNITY_EDITOR
#endif
#if UNITY_EDITOR
using UnityEditor;

View File

@ -1,6 +1,5 @@
#if DISABLE_DEBUGX
#if DISABLE_DEBUG
#undef DEBUG
#undef UNITY_EDITOR
#endif
using DCFApixels.DebugXCore;
using System;

View File

@ -1,6 +1,5 @@
#if DISABLE_DEBUGX
#if DISABLE_DEBUG
#undef DEBUG
#undef UNITY_EDITOR
#endif
using DCFApixels.DebugXCore.Internal;
using UnityEngine;

View File

@ -1,6 +1,5 @@
#if DISABLE_DEBUGX
#if DISABLE_DEBUG
#undef DEBUG
#undef UNITY_EDITOR
#endif
using System;
using UnityEngine;

View File

@ -1,6 +1,5 @@
#if DISABLE_DEBUGX
#if DISABLE_DEBUG
#undef DEBUG
#undef UNITY_EDITOR
#endif
using System.Runtime.CompilerServices;
using UnityEngine;

View File

@ -1,6 +1,5 @@
#if DISABLE_DEBUGX
#if DISABLE_DEBUG
#undef DEBUG
#undef UNITY_EDITOR
#endif
#if UNITY_EDITOR
using UnityEditor;

View File

@ -1,4 +1,8 @@
#undef DEBUG
#if DEBUG
#define DEV_MODE
#endif
using System;
using System.Buffers;
using System.Collections.Generic;
@ -9,6 +13,10 @@ using static DCFApixels.DebugX;
namespace DCFApixels.DebugXCore.Internal
{
using IN = System.Runtime.CompilerServices.MethodImplAttribute;
internal interface IStructListElement<T>
{
void OnSwap(ref T element);
}
[System.Diagnostics.DebuggerDisplay("Count: {Count}")]
internal struct StructList
{
@ -34,6 +42,11 @@ namespace DCFApixels.DebugXCore.Internal
[System.Diagnostics.DebuggerDisplay("Count: {Count}")]
internal struct StructList<T> : IDisposable
{
//private struct Dummy : IStructListElement<T>
//{
// public void OnSwap(ref T element) { }
//}
//private static IStructListElement<T> _internal = default(T) as IStructListElement<T> ?? default(Dummy);
internal T[] _items;
internal int _count;
internal readonly bool _isUseArrayPool;
@ -63,7 +76,7 @@ namespace DCFApixels.DebugXCore.Internal
[IN(LINE)]
get
{
#if DEBUG
#if DEV_MODE
if (index < 0 || index >= _count) { new ArgumentOutOfRangeException(); }
#endif
return _items[index];
@ -71,7 +84,7 @@ namespace DCFApixels.DebugXCore.Internal
[IN(LINE)]
set
{
#if DEBUG
#if DEV_MODE
if (index < 0 || index >= _count) { new ArgumentOutOfRangeException(); }
#endif
_items[index] = value;
@ -104,6 +117,7 @@ namespace DCFApixels.DebugXCore.Internal
public void Add(T item)
{
UpSize(_count + 1);
//_internal.OnSwap(ref item);
_items[_count++] = item;
}
[IN(LINE)]
@ -112,6 +126,7 @@ namespace DCFApixels.DebugXCore.Internal
UpSize(_count + items.Length);
for (int i = 0; i < items.Length; i++)
{
//_internal.OnSwap(ref item);
_items[_count++] = items[i];
}
}
@ -146,33 +161,38 @@ namespace DCFApixels.DebugXCore.Internal
T tmp = _items[idnex1];
_items[idnex1] = _items[idnex2];
_items[idnex2] = tmp;
//_internal.OnSwap(ref _items[idnex1]);
//_internal.OnSwap(ref _items[idnex2]);
}
[IN(LINE)]
public void FastRemoveAt(int index)
{
#if DEBUG
#if DEV_MODE
if (index < 0 || index >= _count) { new ArgumentOutOfRangeException(); }
#endif
_items[index] = _items[--_count];
//_internal.OnSwap(ref _items[index]);
}
[IN(LINE)]
public void RemoveAt(int index)
{
#if DEBUG
#if DEV_MODE
if (index < 0 || index >= _count) { new ArgumentOutOfRangeException(); }
#endif
_items[index] = _items[--_count];
//_internal.OnSwap(ref _items[index]);
_items[_count] = default;
}
[IN(LINE)]
public void RemoveAtWithOrder(int index)
{
#if DEBUG
#if DEV_MODE
if (index < 0 || index >= _count) { new ArgumentOutOfRangeException(); }
#endif
for (int i = index; i < _count; i++)
{
_items[i] = _items[i + 1];
//_internal.OnSwap(ref _items[i]);
}
}
[IN(LINE)]

View File

@ -1,6 +1,5 @@
#if DISABLE_DEBUGX
#if DISABLE_DEBUG
#undef DEBUG
#undef UNITY_EDITOR
#endif
#if UNITY_EDITOR
using UnityEditor;

View File

@ -1,6 +1,8 @@
#if DISABLE_DEBUGX
#if DISABLE_DEBUG
#undef DEBUG
#undef UNITY_EDITOR
#endif
#if DEBUG
#define DEV_MODE
#endif
using System;
using System.Diagnostics;

View File

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