百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
U

Unity-DebugX

> 开发工具
开源

这是一款功能强大、可扩展且性能卓越的 Gizmos 绘图工具,适用于 Unity。它既可在编辑器中使用,也可在构建阶段使用,并且可以进行绘图操作。

185 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

这是一款功能强大、可扩展且性能卓越的 Gizmos 绘图工具,适用于 Unity。它既可在编辑器中使用,也可在构建阶段使用,并且可以进行绘图操作。

Unity-DebugX

Readme Languages:







  
    
    Русский
    


  
    
    English
    


  
    
    中文

A multifunctional, extensible, and high-performance Gizmos drawing utility for Unity. It works both in the editor and in the build, and drawing can be done both in OnDrawGizmos and in Update. HDRP, URP, and BRP are supported, but drawing in the OnDrawGizmos callbacks is not supported in BRP.

Syntax:

csharp
DebugX.Draw(duration, color).*Gizmo Function*(...);

Table of Contents

  • Installation
  • Basic API
  • Settings
  • API Extension
  • Loading Static Assets
  • Define Symbols
  • Projects Using DebugX
  • License

Installation

Versioning semantics - Открыть

Unity-Package

Supports installation as a Unity module. Copy the Git-URL into PackageManager:

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

The Package can also be directly copied into the project folder.

Basic API

The general syntax for drawing predefined Gizmos:

csharp
DebugX.Draw(duration, color).*Gizmo Function*(...);

Among the predefined Gizmos, there are various primitives, lines, points, and text. Examples of some Gizmos:

csharp
// Draws a regular line similar to Debug.DrawLine(...).
// The line will be displayed for one second and will be red.
DebugX.Draw(1, Color.red).Line(startPoint, endPoint);
csharp
// Draws a cube, but for just one frame and in yellow.
DebugX.Draw(Color.yellow).Cube(center, rotation, size);
csharp
// Draws a sphere.
DebugX.Draw(Color.yellow).Cube(center, radius);
csharp
// Draws a point. The point has a screen space size. 
DebugX.Draw(Color.yellow).Dot(startPoint, endPoint);
csharp
// Draws text. The text can also be displayed for the specified time.
DebugX.Draw(1, Color.red).Text(center, text);
// For advanced display settings, use DebugXTextSettings.
DebugX.Draw(Color.yellow).Text(center, text, DebugXTextSettings.Default.SetBackgroundColor(Color.black));

In case the predefined primitives are not enough, there are methods for drawing custom meshes and materials:

csharp
//Рисования любого меша lit материалом. Без GPU instancing. 
DebugX.Draw(...).Mesh(mesh, pos, rot, sc);
//UnlitMesh - меш с unlit материалом
//WireMesh - меш с wireframe материалом
csharp
//Рисования статического меша lit материалом. В режиме GPU instancing. 
DebugX.Draw(...).Mesh(pos, rot, sc);
//UnlitMesh - меш с unlit материалом
//WireMesh - меш с wireframe материалом
csharp
//Рисования статического меша статическим материалом. В режиме GPU instancing. 
DebugX.Draw(...).Mesh(pos, rot, sc);

Static data is used to optimize the rendering:

csharp
// Static mesh. Required for drawing with GPU instancing.
public struct SomeMesh : IStaticMesh
{
    public Mesh GetMesh() => StaticStorage.SomeMesh;
}
csharp
// Static material.
public struct SomeMesh : IStaticMesh
{
    // Control the drawing order.
    public int GetExecuteOrder() => 100;
    public Mesh GetMaterial() => StaticStorage.SomeMaterial;
} 

In the example, StaticStorage is a conditional implementation of a static asset storage. Since in Unity static data cannot be filled through the inspector, the solution to this problem is described in the section Loading Static Assets.

Settings

Settings window "Tools -> DebugX -> Settings":

API Extension

The simplest option is to create an extension method that combines predefined gizmos, for example:

csharp
public static class SomeGizmoExtensions
{
    public static DebugX.DrawHandler Distance(this DebugX.DrawHandler self, Vector3 start, Vector3 end)
    {
        // Draw a line.
        self.Line(start, end);
        // Draw text in the middle of the line showing the length of the line.
        self.Text(Vector3.Lerp(start, end, 0.5f), Vector3.Distance(start, end), DebugXTextSettings.Default.SetAnchor(TextAnchor.UpperCenter));
        // for support Method Chaining syntax.
        return self;
    }
}

You can also use the Mesh methods to create drawing methods for other primitives.

Extended implementation of Gizmo, in case the built-in drawing methods are not enough:

…
csharp
// Create an extension method. 
public static class SomeGizmoExtensions
{
    public static DebugX.DrawHandler SomeGizmo(this DebugX.DrawHandler self, /*...*/) 
    {
        self.Gizmo(new SomeGizmo(/*...*/);
        return self;
    }
}

Loading Static Assets

Для загрузки имеется утилита DebugXUtility.LoadStaticData(...);.

  1. First, create a storage for the assets.
csharp
public readonly struct SomeAssets
{
    public readonly Mesh SomeMesh;
    public readonly Material SomeMaterial;
} 
  1. Next, create a prefab with a list of assets. Each child GameObject of the prefab is treated as one asset, and its name must match the field where the asset will be loaded. To load meshes, add a MeshFilter component to the GameObject with a reference to the desired mesh. To load a material, add any component inherited from Renderer with the specified material. The prefab itself must be located in the Resources folder.

  2. Once the repository and prefab list are prepared, assets can be uploaded.

csharp
SomeAssets assets = DebugXUtility.LoadStaticData(new SomeAssets(), "SomeAssets");
// Done.

An example of how to work with this utility can be found in the source code in the file DebugXAssets.cs.

Define Symbols

All Define Symbols can be changed in the settings window

  • DEBUGX_DISABLE_INBUILD - By default, Gizmos will be drawn in the project build. This define disables drawing.
  • DEBUGX_ENABLE_PHYSICS2D - Enable Physics2D Gizmos.
  • DEBUGX_ENABLE_PHYSICS3D - Enable Physics3D Gizmos.

Projects Using DebugX

    Clear And Move
    
   


  
    Order matters
    
   








  
    Crystal Siege
    
   


  
    ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ

License

The MIT License: https://raw.githubusercontent.com/DCFApixels/Unity-DebugX/refs/heads/main/LICENSE.md

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C#debugdebuggergizmogizmos

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类开发工具
定价开源

> 相关工具

V
VS Code
流行的开源代码编辑器
G
Git
分布式版本控制系统
V
Vite
下一代前端构建工具