mirror of
https://github.com/DCFApixels/Unity-DebugX.git
synced 2025-09-18 18:14:36 +08:00
stash
This commit is contained in:
parent
bc8f2cedf1
commit
c2794bf715
@ -14,12 +14,13 @@ using Unity.Collections.LowLevel.Unsafe;
|
||||
using DCFApixels.DebugXCore.Internal;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
#endif
|
||||
|
||||
namespace DCFApixels
|
||||
{
|
||||
using static DebugXConsts;
|
||||
using static UnityEngine.PlayerLoop.PostLateUpdate;
|
||||
using IN = System.Runtime.CompilerServices.MethodImplAttribute;
|
||||
public static unsafe partial class DebugX
|
||||
{
|
||||
@ -34,6 +35,10 @@ namespace DCFApixels
|
||||
private static ulong _renderTicks = 100;
|
||||
private static ulong _timeTicks = 0;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private static (MethodInfo method, DebugXDrawGizmoAttribute attribute)[] _drawGizmosMethods;
|
||||
#endif
|
||||
|
||||
public static ulong RenderTicks
|
||||
{
|
||||
get { return _renderTicks; }
|
||||
@ -70,7 +75,6 @@ namespace DCFApixels
|
||||
{
|
||||
InitGlobals();
|
||||
|
||||
|
||||
if (IsSRP)
|
||||
{
|
||||
RenderPipelineManager.beginCameraRendering -= OnPreRender_SRP;
|
||||
@ -115,7 +119,9 @@ namespace DCFApixels
|
||||
//Application.onBeforeRender -= Application_onBeforeRender;
|
||||
//Application.onBeforeRender += Application_onBeforeRender;
|
||||
|
||||
|
||||
#if UNITY_EDITOR
|
||||
_drawGizmosMethods = TypeCache.GetMethodsWithAttribute<DebugXDrawGizmoAttribute>().Select(o => (o, o.GetCustomAttribute<DebugXDrawGizmoAttribute>())).ToArray();
|
||||
EditorApplication.pauseStateChanged -= EditorApplication_pauseStateChanged;
|
||||
EditorApplication.pauseStateChanged += EditorApplication_pauseStateChanged;
|
||||
EditorApplication.update -= EditorApplication_update;
|
||||
@ -302,6 +308,24 @@ namespace DCFApixels
|
||||
|
||||
if (DebugXUtility.IsGizmosRender())
|
||||
{
|
||||
if(_drawGizmosMethods.Length > 0)
|
||||
{
|
||||
object[] oneObjParams = new object[1];
|
||||
for (int i = 0; i < _drawGizmosMethods.Length; i++)
|
||||
{
|
||||
var pair = _drawGizmosMethods[i];
|
||||
var objects = UnityEngine.Object.FindObjectsByType(pair.attribute.Type, FindObjectsInactive.Exclude, FindObjectsSortMode.None);
|
||||
for (int j = 0; j < objects.Length; j++)
|
||||
{
|
||||
oneObjParams[0] = objects[j];
|
||||
pair.method.Invoke(null, oneObjParams);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
RenderContextController.StaicContextController.Prepare();
|
||||
RenderContextController.StaicContextController.Render(cbExecutor);
|
||||
cbExecutor.Submit();
|
||||
|
14
Runtime/Utils/DebugXDrawGizmoAttribute.cs
Normal file
14
Runtime/Utils/DebugXDrawGizmoAttribute.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
|
||||
namespace DCFApixels.DebugXCore
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Method, Inherited = false, AllowMultiple = false)]
|
||||
public sealed class DebugXDrawGizmoAttribute : Attribute
|
||||
{
|
||||
public Type Type;
|
||||
public DebugXDrawGizmoAttribute(Type type)
|
||||
{
|
||||
Type = type;
|
||||
}
|
||||
}
|
||||
}
|
2
Runtime/Utils/DebugXDrawGizmoAttribute.cs.meta
Normal file
2
Runtime/Utils/DebugXDrawGizmoAttribute.cs.meta
Normal file
@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 884ed13700ff7c44e86f92c859f02dc5
|
@ -13,16 +13,22 @@ namespace DCFApixels.DebugXCore.Samples
|
||||
public float WidthMultiplier = 1f;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private void OnDrawGizmos()
|
||||
{
|
||||
Draw();
|
||||
}
|
||||
//private void OnDrawGizmos()
|
||||
//{
|
||||
// Draw();
|
||||
//}
|
||||
#else
|
||||
private void Update()
|
||||
{
|
||||
Draw();
|
||||
}
|
||||
#endif
|
||||
[DebugXDrawGizmo(typeof(DebugXSample_Lines))]
|
||||
private static void DrawGizmos(DebugXSample_Lines obj)
|
||||
{
|
||||
obj.Draw();
|
||||
}
|
||||
|
||||
private void Draw()
|
||||
{
|
||||
int i = -1;
|
||||
|
Loading…
Reference in New Issue
Block a user