Merge branch 'dev_text' into dev

This commit is contained in:
DCFApixels 2025-02-28 11:22:27 +08:00
commit 85891817ff
19 changed files with 635 additions and 113 deletions

View File

@ -29,7 +29,7 @@ namespace DCFApixels
private enum PauseStateX
private enum DebugXPauseState
{
Unpaused = 0,
PreUnpaused = 1, //нужно чтобы отщелкунть паузу с задержкой в один тик

View File

@ -22,14 +22,14 @@ namespace DCFApixels
using IN = System.Runtime.CompilerServices.MethodImplAttribute;
public static unsafe partial class DebugX
{
private static PauseStateX _pauseState = PauseStateX.Unpaused;
private static DebugXPauseState _pauseState = DebugXPauseState.Unpaused;
private static bool _isCameraContext = false;
private static ulong _lastEditorTicks = 1000;
private static double _lastUnityTime;
private static float _deltaTime = 0;
private static ulong _editorTicks = 0;
private static ulong _lastEditorToRenderTicks = 1000;
private static ulong _renderTicks = 100;
private static ulong _timeTicks = 0;
@ -59,7 +59,7 @@ namespace DCFApixels
#if UNITY_EDITOR
private static void EditorApplication_pauseStateChanged(PauseState obj)
{
_pauseState = obj == PauseState.Paused ? PauseStateX.Paused : PauseStateX.PreUnpaused;
_pauseState = obj == PauseState.Paused ? DebugXPauseState.Paused : DebugXPauseState.PreUnpaused;
}
#endif
#endregion
@ -228,12 +228,10 @@ namespace DCFApixels
private static void OnPreRender_BRP(Camera camera)
{
PreRender_General(camera);
//throw new NotImplementedException();
}
private static void OnPostRender_BRP(Camera camera)
{
PostRender_General(CommandBufferExecutorBRP.GetInstance(), camera);
//throw new NotImplementedException();
}
private static void PreUpdateCallback()
@ -244,7 +242,7 @@ namespace DCFApixels
if (_lastUnityTime < Time.unscaledTimeAsDouble)
{
_timeTicks++;
if (_pauseState == PauseStateX.Unpaused)
if (_pauseState == DebugXPauseState.Unpaused)
{
_deltaTime = Time.unscaledDeltaTime * _timeScaleCache;
}
@ -263,9 +261,9 @@ namespace DCFApixels
}
}
_lastUnityTime = Time.unscaledTimeAsDouble;
if (_pauseState == PauseStateX.PreUnpaused)
if (_pauseState == DebugXPauseState.PreUnpaused)
{
_pauseState = PauseStateX.Unpaused;
_pauseState = DebugXPauseState.Unpaused;
}
SetGameSceneContext();
}
@ -288,19 +286,21 @@ namespace DCFApixels
_currentCamera = camera;
}
private static void PostRender_General(ICommandBufferExecutor cbExecutor, Camera camera)
{
if (_lastEditorTicks != _editorTicks)
if (_lastEditorToRenderTicks != _editorTicks)
{
_renderTicks++;
_lastEditorTicks = _editorTicks;
_lastEditorToRenderTicks = _editorTicks;
}
if (DebugXUtility.IsGizmosRender())
{
RenderContextController.StaicContextController.Prepare();
RenderContextController.StaicContextController.Render(cbExecutor);
cbExecutor.Submit();
RenderContextController.StaicContextController.PostRender();
RenderContextController.StaicContextController.RunEnd();
}
if (camera == null) { return; }
@ -308,34 +308,10 @@ namespace DCFApixels
RenderContextController contextController = RenderContextController.GetController(new RenderContext(camera));
contextController.Prepare();
contextController.Render(cbExecutor);
cbExecutor.Submit();
contextController.PostRender();
contextController.RunEnd();
}
#if UNITY_EDITOR
[DrawGizmo(GizmoType.NonSelected | GizmoType.Selected)]
private static void DrawGizmos(Camera obj, GizmoType gizmoType)
{
if (obj != Camera.main) { return; }
Camera camera = Camera.current;
Color guiColor = GUI.color;
Color gizmosColor = Gizmos.color;
Color handlesColor = Handles.color;
GL.MultMatrix(Handles.matrix);
RenderContextController.StaicContextController.Render_UnityGizmos();
if (camera == null) { return; }
_currentCamera = camera;
RenderContextController.GetController(new RenderContext(camera)).Render_UnityGizmos();
GUI.color = guiColor;
Gizmos.color = gizmosColor;
Handles.color = handlesColor;
}
#endif
#endregion
@ -532,7 +508,6 @@ namespace DCFApixels
// //}
//}
[IN(LINE)]
public void Prepare()
{
@ -558,15 +533,12 @@ namespace DCFApixels
{
_buffers[i].Render(cbExecutor);
}
RunEnd();
}
}
[IN(LINE)]
public void Render_UnityGizmos()
public void PostRender()
{
#if UNITY_EDITOR
using (_cameraMarker.Auto())
@ -574,7 +546,7 @@ namespace DCFApixels
{
for (int i = 0, iMax = _buffers.Count; i < iMax; i++)
{
_buffers[i].Render_UnityGizmos();
_buffers[i].PostRender();
}
}
}
@ -603,7 +575,7 @@ namespace DCFApixels
public abstract int UpdateTimer(float deltaTime);
public abstract void Prepare();
public abstract void Render(ICommandBufferExecutor cbExecutor);
public abstract void Render_UnityGizmos();
public abstract void PostRender();
public abstract int RunEnd();
public abstract void Clear();
}
@ -626,7 +598,7 @@ namespace DCFApixels
//private readonly CommandBuffer _dynamicCommandBuffer;
private readonly IGizmoRenderer<T> _renderer;
private readonly IGizmoRenderer_UnityGizmos<T> _rendererUnityGizmos;
private readonly IGizmoRenderer_PostRender<T> _rendererUnityGizmos;
private readonly bool _isStatic;
#if DEV_MODE
@ -653,7 +625,7 @@ namespace DCFApixels
_renderer = new DummyRenderer();
}
_isStatic = _renderer.IsStaticRender;
_rendererUnityGizmos = _renderer as IGizmoRenderer_UnityGizmos<T>;
_rendererUnityGizmos = _renderer as IGizmoRenderer_PostRender<T>;
All.Add(this);
All.Sort((a, b) => a.ExecuteOrder - b.ExecuteOrder);
@ -697,6 +669,7 @@ namespace DCFApixels
}
return removeCount;
}
public sealed override int RunEnd()
{
int removeCount = 0;
@ -771,9 +744,10 @@ namespace DCFApixels
cbExecutor.Execute(_staticCommandBuffer);
}
}
public override void Render_UnityGizmos()
public override void PostRender()
{
if (_rendererUnityGizmos == null) { return; }
//Debug.Log(_gizmos._count);
if (_gizmos.Count <= 0) { return; }
#if DEV_MODE
using (_renderMarker.Auto())
@ -782,7 +756,7 @@ namespace DCFApixels
GizmosList<T> list = GizmosList.From(_gizmos._items, _gizmos._count);
try
{
_rendererUnityGizmos.Render_UnityGizmos(GetCurrentCamera(), list);
_rendererUnityGizmos.PostRender(GetCurrentCamera(), list);
}
catch (Exception e) { throw new Exception($"[{_debugName}] [Render] ", e); }
}

View File

@ -222,58 +222,6 @@ namespace DCFApixels
}
#endregion
#region Text
[IN(LINE)] public DrawHandler Text(Vector3 position, object text) => Gizmo(new TextGizmo(position, text));
private readonly struct TextGizmo : IGizmo<TextGizmo>
{
public readonly Vector3 Position;
public readonly string Text;
[IN(LINE)]
public TextGizmo(Vector3 position, object text)
{
Position = position;
Text = text.ToString();
}
public IGizmoRenderer<TextGizmo> RegisterNewRenderer() { return new Renderer(); }
#region Renderer
private class Renderer : IGizmoRenderer_UnityGizmos<TextGizmo>
{
private static GUIStyle _labelStyle;
private static GUIContent _labelDummy;
public int ExecuteOrder => default(UnlitMat).GetExecuteOrder();
public bool IsStaticRender => false;
public void Prepare(Camera camera, GizmosList<TextGizmo> list) { }
public void Render(Camera camera, GizmosList<TextGizmo> list, CommandBuffer cb) { }
public void Render_UnityGizmos(Camera camera, GizmosList<TextGizmo> list)
{
#if UNITY_EDITOR
Color defaultColor = GUI.color;
if (_labelStyle == null || _labelDummy == null)
{
_labelStyle = GUI.skin.label;
_labelStyle.richText = false;
_labelDummy = new GUIContent();
}
Handles.BeginGUI();
foreach (ref readonly var item in list)
{
GUI.color = item.Color * GlobalColor;
_labelDummy.text = item.Value.Text;
if (!(HandleUtility.WorldToGUIPointWithDepth(item.Value.Position).z < 0f))
{
GUI.Label(HandleUtility.WorldPointToSizedRect(item.Value.Position, _labelDummy, _labelStyle), _labelDummy, _labelStyle);
}
}
Handles.EndGUI();
GUI.color = defaultColor;
#endif
}
}
#endregion
}
#endregion
// Base Renderers
#region MeshRendererBase

View File

@ -0,0 +1,244 @@
using DCFApixels.DebugXCore;
#if UNITY_EDITOR
using UnityEditor;
#endif
using UnityEngine;
using UnityEngine.Rendering;
namespace DCFApixels
{
using IN = System.Runtime.CompilerServices.MethodImplAttribute;
public static partial class DebugX
{
public readonly partial struct DrawHandler
{
#region Text
[IN(LINE)] public DrawHandler Text(Vector3 position, object text) => Gizmo(new TextGizmo(position, text, DebugXTextSettings.Default));
[IN(LINE)] public DrawHandler Text(Vector3 position, object text, DebugXTextSettings settings) => Gizmo(new TextGizmo(position, text, settings));
private readonly struct TextGizmo : IGizmo<TextGizmo>
{
public readonly Vector3 Position;
public readonly string Text;
public readonly DebugXTextSettings Settings;
[IN(LINE)]
public TextGizmo(Vector3 position, object text, DebugXTextSettings settings)
{
Position = position;
Text = text.ToString();
Settings = settings;
}
public IGizmoRenderer<TextGizmo> RegisterNewRenderer() { return new Renderer(); }
#region Renderer
private class Renderer : IGizmoRenderer_PostRender<TextGizmo>
{
private static GUIStyle _labelStyle;
private static GUIContent _labelDummy;
private static Texture2D _whiteTexture;
public int ExecuteOrder => default(UnlitMat).GetExecuteOrder();
public bool IsStaticRender => false;
public void Prepare(Camera camera, GizmosList<TextGizmo> list) { }
public void Render(Camera camera, GizmosList<TextGizmo> list, CommandBuffer cb) { }
public void PostRender(Camera camera, GizmosList<TextGizmo> list)
{
if (camera == null) { return; }
if (Event.current.type != EventType.Repaint) { return; }
Color dfColor = GUI.color;
InitStatic();
bool isSceneView = false;
var backgroundMaterial = DebugXAssets.Materials.TextBackground;
#if UNITY_EDITOR
//TODO костыльный вариант, нужно поискать более надежный способ определить рендер SceneView
isSceneView = camera.name == "SceneCamera";
#endif
if (isSceneView)
{
#if UNITY_EDITOR
Handles.BeginGUI();
#endif
}
else
{
GL.PushMatrix();
GL.LoadPixelMatrix(0, Screen.width, Screen.height, 0);
}
foreach (ref readonly var item in list)
{
_labelDummy.text = item.Value.Text;
GUIStyle style = _labelStyle;
var zoom = GetCameraZoom(camera, item.Value.Position);
style.fontSize = Mathf.FloorToInt(Mathf.Lerp(item.Value.Settings.FontSize, item.Value.Settings.FontSize / zoom, item.Value.Settings.WorldSpaceScaleFactor));
style.alignment = item.Value.Settings.TextAnchor;
if (!(WorldToGUIPointWithDepth(camera, item.Value.Position).z < 0f))
{
Rect rect = WorldPointToSizedRect(camera, item.Value.Position, _labelDummy, _labelStyle);
Color backgroundColor = item.Value.Settings.BackgroundColor * GlobalColor;
backgroundMaterial.SetColor(ColorPropertyID, backgroundColor);
Graphics.DrawTexture(rect, _whiteTexture, backgroundMaterial);
GUI.color = item.Color * GlobalColor;
style.Draw(rect, _labelDummy, false, false, false, false);
}
}
GUI.color = dfColor;
backgroundMaterial.SetColor(ColorPropertyID, Color.white);
if (isSceneView)
{
#if UNITY_EDITOR
Handles.EndGUI();
#endif
}
else
{
GL.PopMatrix();
}
}
#region Init
private void InitStatic()
{
if (_labelStyle == null || _labelDummy == null || _whiteTexture == null)
{
GUIStyleState GenerateGUIStyleState()
{
var result = new GUIStyleState();
result.textColor = Color.white;
result.background = null;
return result;
}
GUISkin skin = (GUISkin)typeof(GUI).GetField("s_Skin", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static).GetValue(null); //GUI.s_Skin
//GUISkin skin = GUI.skin;
_labelStyle = new GUIStyle(skin.label)
{
richText = false,
padding = new RectOffset(1, 1, 0, 0),
margin = new RectOffset(0, 0, 0, 0),
normal = GenerateGUIStyleState(),
active = GenerateGUIStyleState(),
hover = GenerateGUIStyleState(),
focused = GenerateGUIStyleState(),
};
_labelDummy = new GUIContent();
_whiteTexture = new Texture2D(2, 2);
Color32[] color = new Color32[]
{
Color.white,
Color.white,
Color.white,
Color.white,
};
_whiteTexture.SetPixels32(color);
_whiteTexture.Apply();
}
}
#endregion
#region Utils
public static Vector3 WorldToGUIPointWithDepth(Camera camera, Vector3 world)
{
#if UNITY_EDITOR
world = Handles.matrix.MultiplyPoint(world);
#endif
Vector3 vector = camera.WorldToScreenPoint(world);
vector.y = camera.pixelHeight - vector.y;
Vector2 vector2 = (Vector2)(vector);
#if UNITY_EDITOR
vector2 = EditorGUIUtility.PixelsToPoints(vector);
#endif
return new Vector3(vector2.x, vector2.y, vector.z);
}
public static Rect WorldPointToSizedRect(Camera camera, Vector3 position, GUIContent content, GUIStyle style)
{
Vector2 vector = (Vector2)WorldToGUIPointWithDepth(camera, position);
Vector2 vector2 = style.CalcSize(content);
Rect rect = new Rect(vector.x, vector.y, vector2.x, vector2.y);
switch (style.alignment)
{
case TextAnchor.UpperCenter:
rect.x -= rect.width * 0.5f;
break;
case TextAnchor.UpperRight:
rect.x -= rect.width;
break;
case TextAnchor.MiddleLeft:
rect.y -= rect.height * 0.5f;
break;
case TextAnchor.MiddleCenter:
rect.x -= rect.width * 0.5f;
rect.y -= rect.height * 0.5f;
break;
case TextAnchor.MiddleRight:
rect.x -= rect.width;
rect.y -= rect.height * 0.5f;
break;
case TextAnchor.LowerLeft:
rect.y -= rect.height;
break;
case TextAnchor.LowerCenter:
rect.x -= rect.width * 0.5f;
rect.y -= rect.height;
break;
case TextAnchor.LowerRight:
rect.x -= rect.width;
rect.y -= rect.height;
break;
}
return style.padding.Add(rect);
}
private static float GetCameraZoom(Camera camera, Vector3 position)
{
position = Handles.matrix.MultiplyPoint(position);
Transform transform = camera.transform;
Vector3 position2 = transform.position;
float z = Vector3.Dot(position - position2, transform.TransformDirection(new Vector3(0f, 0f, 1f)));
Vector3 vector = camera.WorldToScreenPoint(position2 + transform.TransformDirection(new Vector3(0f, 0f, z)));
Vector3 vector2 = camera.WorldToScreenPoint(position2 + transform.TransformDirection(new Vector3(1f, 0f, z)));
float magnitude = (vector - vector2).magnitude;
return 80f / Mathf.Max(magnitude, 0.0001f) * EditorGUIUtility.pixelsPerPoint;
//const float DEFAULT_ZOOM = 1f;
//
//if (camera != null)
//{
// return camera.orthographicSize;
//}
//return DEFAULT_ZOOM;
//var currentDrawingSceneView = SceneView.currentDrawingSceneView;
//
//if (currentDrawingSceneView == null)
//{
// return DEFAULT_ZOOM;
//}
//
//var localCamera = currentDrawingSceneView.camera;
//
//if (localCamera != null)
//{
// return localCamera.orthographicSize;
//}
//
//return DEFAULT_ZOOM;
}
#endregion
}
#endregion
}
#endregion
}
}
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: c465dc7f5c78c9549a063ecfc5e8326d

View File

@ -7,6 +7,7 @@ namespace DCFApixels.DebugXCore.Internal
internal interface ICommandBufferExecutor
{
void Execute(CommandBuffer cb);
void Submit();
}
internal class CommandBufferExecutorSRP : ICommandBufferExecutor
{
@ -24,6 +25,10 @@ namespace DCFApixels.DebugXCore.Internal
{
RenderContext.ExecuteCommandBuffer(cb);
}
public void Submit()
{
RenderContext.Submit();
}
}
internal class CommandBufferExecutorBRP : ICommandBufferExecutor
{
@ -39,5 +44,6 @@ namespace DCFApixels.DebugXCore.Internal
{
Graphics.ExecuteCommandBuffer(cb);
}
public void Submit() { }
}
}

View File

@ -0,0 +1,135 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: TextBackground
m_Shader: {fileID: 4800000, guid: 1af3913ae49e790418a8d901f8982caf, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses:
- MOTIONVECTORS
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BaseMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_Lightmaps:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_LightmapsInd:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_ShadowMasks:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _AddPrecomputedVelocity: 0
- _AlphaClip: 0
- _AlphaToMask: 0
- _Blend: 0
- _BlendModePreserveSpecular: 1
- _BumpScale: 1
- _ClearCoatMask: 0
- _ClearCoatSmoothness: 0
- _Cull: 2
- _Cutoff: 0.5
- _DetailAlbedoMapScale: 1
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _DstBlendAlpha: 0
- _EnvironmentReflections: 1
- _GlossMapScale: 0
- _Glossiness: 0
- _GlossyReflections: 0
- _Metallic: 0
- _OcclusionStrength: 1
- _Parallax: 0.005
- _QueueOffset: 0
- _ReceiveShadows: 1
- _Smoothness: 0.5
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _SrcBlendAlpha: 1
- _Surface: 0
- _WorkflowMode: 1
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: []
m_AllowLocking: 1
--- !u!114 &1974214919826471110
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 9

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 75409b93d220f694aa75eee6f4bfd840
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -86,6 +86,92 @@ MeshRenderer:
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!1 &549390746132496352
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7483746332942052062}
- component: {fileID: 6763744428275037148}
- component: {fileID: 387838602774759695}
m_Layer: 0
m_Name: TextBackground
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &7483746332942052062
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 549390746132496352}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 12.5, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 2844384060761577604}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &6763744428275037148
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 549390746132496352}
m_Mesh: {fileID: 4300000, guid: 873de0939b7f76947a258a8897199a8e, type: 2}
--- !u!23 &387838602774759695
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 549390746132496352}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RayTracingAccelStructBuildFlagsOverride: 0
m_RayTracingAccelStructBuildFlags: 1
m_SmallMeshCulling: 1
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 75409b93d220f694aa75eee6f4bfd840, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!1 &1299980064020930364
GameObject:
m_ObjectHideFlags: 0
@ -292,6 +378,7 @@ Transform:
- {fileID: 2770005348449356163}
- {fileID: 5119875421667202613}
- {fileID: 1046323005297189095}
- {fileID: 7483746332942052062}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &6563773915565914195

View File

@ -0,0 +1,59 @@
Shader "DCFApixels/DebugX/TextBackground"
{
Properties
{
_Color ("Color", Color) = (1,1,1,1)
}
SubShader
{
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" }
Blend SrcAlpha OneMinusSrcAlpha
ZWrite Off Fog { Mode Off }
Lighting Off
ZTest Off
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_instancing
#include "UnityCG.cginc"
struct appdata_t
{
float4 vertex : POSITION;
float4 color : COLOR;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 vertex : SV_POSITION;
float4 color : COLOR;
};
UNITY_INSTANCING_BUFFER_START(Props)
UNITY_DEFINE_INSTANCED_PROP(float4, _Color)
UNITY_INSTANCING_BUFFER_END(Props)
float4 _DebugX_GlobalColor;
v2f vert (appdata_t v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
o.vertex = UnityObjectToClipPos(v.vertex);
o.color = v.color * UNITY_ACCESS_INSTANCED_PROP(Props, _Color) * _DebugX_GlobalColor;
return o;
}
float4 frag (v2f i) : SV_Target
{
return i.color * float4(1, 1, 1, 2);
}
ENDCG
}
}
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 1af3913ae49e790418a8d901f8982caf
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -47,6 +47,8 @@ namespace DCFApixels.DebugXCore
public readonly Material Billboard;
public readonly Material Dot;
public readonly Material Wire;
internal readonly Material TextBackground;
}
}
}

View File

@ -0,0 +1,45 @@
using UnityEngine;
namespace DCFApixels
{
public readonly struct DebugXTextSettings
{
public const TextAnchor DEFAULT_TEXT_ANCHOR = TextAnchor.MiddleLeft;
public const int DEFAULT_FONT_SIZE = 16;
public static readonly DebugXTextSettings Default = new DebugXTextSettings(DEFAULT_FONT_SIZE, DEFAULT_TEXT_ANCHOR, default, 0);
public static readonly DebugXTextSettings WorldSpaceScale = Default.SetWorldSpaceScaleFactor(1f);
public readonly int FontSize;
public readonly TextAnchor TextAnchor;
public readonly Color BackgroundColor;
public readonly float WorldSpaceScaleFactor;
public bool IsHasBackground
{
get { return BackgroundColor.a > 0; }
}
public DebugXTextSettings(int fontSize, TextAnchor textAnchor, Color backgroundColor, float worldSpaceScaleFactor)
{
FontSize = fontSize;
TextAnchor = textAnchor;
BackgroundColor = backgroundColor;
WorldSpaceScaleFactor = worldSpaceScaleFactor;
}
public DebugXTextSettings SetSize(int fontSize)
{
return new DebugXTextSettings(fontSize, TextAnchor, BackgroundColor, WorldSpaceScaleFactor);
}
public DebugXTextSettings SetAnchor(TextAnchor textAnchor)
{
return new DebugXTextSettings(FontSize, textAnchor, BackgroundColor, WorldSpaceScaleFactor);
}
public DebugXTextSettings SetBackground(Color backgroundColor)
{
return new DebugXTextSettings(FontSize, TextAnchor, backgroundColor, WorldSpaceScaleFactor);
}
public DebugXTextSettings SetWorldSpaceScaleFactor(float factor)
{
return new DebugXTextSettings(FontSize, TextAnchor, BackgroundColor, factor);
}
}
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 5a9b0ba5a6770294b9777fca87f3b7a4

View File

@ -17,9 +17,9 @@ namespace DCFApixels.DebugXCore
void Prepare(Camera camera, GizmosList<T> list);
void Render(Camera camera, GizmosList<T> list, CommandBuffer cb);
}
public interface IGizmoRenderer_UnityGizmos<T> : IGizmoRenderer<T> where T : IGizmo<T>
public interface IGizmoRenderer_PostRender<T> : IGizmoRenderer<T> where T : IGizmo<T>
{
void Render_UnityGizmos(Camera camera, GizmosList<T> list);
void PostRender(Camera camera, GizmosList<T> list);
}

View File

@ -135,14 +135,14 @@ Material:
- _GlossinessSource: 0
- _GlossyReflections: 1
- _LightingEnabled: 1
- _Metallic: 0
- _Metallic: 0.046
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _QueueOffset: 0
- _ReceiveShadows: 0
- _Shininess: 0
- _Smoothness: 0
- _Smoothness: 0.047
- _SmoothnessSource: 0
- _SmoothnessTextureChannel: 0
- _SoftParticlesEnabled: 0

View File

@ -1229,7 +1229,7 @@ Camera:
m_ShutterSpeed: 0.005
m_Aperture: 16
m_FocusDistance: 10
m_FocalLength: 50
m_FocalLength: 20.78461
m_BladeCount: 5
m_Curvature: {x: 2, y: 11}
m_BarrelClipping: 0.25
@ -1244,7 +1244,7 @@ Camera:
height: 1
near clip plane: 0.3
far clip plane: 1000
field of view: 60
field of view: 60.000004
orthographic: 0
orthographic size: 5
m_Depth: -1
@ -1277,7 +1277,7 @@ Transform:
m_Children:
- {fileID: 1800693605}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 60, y: 0, z: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &298618463
MonoBehaviour:
m_ObjectHideFlags: 0

View File

@ -20,7 +20,6 @@ namespace DCFApixels.DebugXCore.Samples
Draw();
}
#endif
private void Draw()
{
int i = -1;
@ -29,7 +28,9 @@ namespace DCFApixels.DebugXCore.Samples
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])).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);
Color backgroundColor = Color.white - GetColor(Points[i]);
backgroundColor.a = 0.5f;
i++; DebugX.Draw(GetColor(Points[i])).Text(Points[i].position, Points[i].name, DebugXTextSettings.Default.SetBackground(backgroundColor));
i++; DebugX.Draw(GetColor(Points[i])).Dot(Points[i].position);
i++; DebugX.Draw(GetColor(Points[i])).WireDot(Points[i].position);