Giter Club home page Giter Club logo

vertx.debugging's Introduction

Unity Utilities

  • NSelection - Select Objects behind others in the scene-view hassle-free. Collapse hierarchies to your selection.
  • Debugging - Editor debug drawing for physics casts, shapes, text, and gizmos.
  • Utilities - A core package that contains many resources I use daily. This is required to allow the below packages to function.
    • Editors - Extensions to Unity's built-in editors that add basic navigation improvements. Easily find other scriptable objects of similar types, select assets from scripts, all in an extremely built-in feeling manner.
    • SerializeReference Dropdown - Adds a decorator for SerializeReference fields.
  • Attributes - Property Attributes and Drawers.

Unity Troubleshooting

I maintain a website for troubleshooting basic Unity issues often asked on the Unity Discord here.
It can be contributed to here.

Developer Notes

I developed and curate Developer Notes ๐Ÿ’ฌ, a browser extension that displays shared comments on gamedev documentation. There have been hundreds of notes contributed, a significant portion of which are my own.

Discord

I moderate the Unity Discord and am developing helper tools to maintain its resources and enhance its moderation.

Me

๐ŸŽต Come join me on Bandcamp.
โ˜• Support me by buying me a coffee:

ko-fi

vertx.debugging's People

Contributors

boxfriend avatar rhys-vdw avatar vertxxyz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vertx.debugging's Issues

Custom line drawing

Avoiding using Debug and Gizmos would mean that line drawing can be more advanced, and more performant.
It also enables things like single-sided (or different rendering for backfaces) that help distinguish which face of a 3D shape is internal.

Render Collider2D at actual transform position

Is there any chance drawing a collider2D at the actual transform position, including z, would be possible?

Supporting z position for my project is essential, so if you're not interested in the feature, perhaps you could help me understand how this is zeroing the z position? Then I can make my own forked IDrawables.

Matrix4x4 handleMatrix = boxCollider.transform.localToWorldMatrix;
handleMatrix.SetRow(0, Vector4.Scale(handleMatrix.GetRow(0), new Vector4(1f, 1f, 0f, 1f)));
handleMatrix.SetRow(1, Vector4.Scale(handleMatrix.GetRow(1), new Vector4(1f, 1f, 0f, 1f)));
handleMatrix.SetRow(2, new Vector4(0f, 0f, 1f, boxCollider.transform.position.z));
Matrix = handleMatrix * Matrix4x4.TRS(boxCollider.offset, Quaternion.identity, ColliderLocalSize(boxCollider));

Annoying Package error

Hi. I have an annoying console error: Asset Packages/com.vertx.debugging/Editor/Assets has no meta file, but it's in an immutable folder. The asset will be ignored.

Unity 2021.3.15
com.vertx.debugging v2.0.4 OpenUPM

Please add .meta file for the Assets folder to fix it ;)

Support Burst/Jobs

I've started full-time work so this is on hold, but I would love to make this happen. There's a branch, but it's in a crashing state.

Add overloads for Unity.Mathematics types.

I will likely still store these types as built-in internally to avoid a dependency and the slow nature of Mathematics when unbursted.

This would be good for uncastable things like LineStrip.

Null references

Hi. I found some issues with nullable.

I have this code. Just Capsule Cast.

var result = Physics2D.CapsuleCast(origin, size, CapsuleDirection2D.Vertical, 0, direction, maxDistance, layerMask);
D.raw(new Shape.CapsuleCast2D(origin, size, CapsuleDirection2D.Vertical, 0, direction, result, maxDistance, layerMask), Color.blue, DrawPhysicsSettings.Duration);

After that, I has null ref here
CastCapsuleHasValueNoTransform

Hit has value but Hit.Transform is null.
I has this issue with other casts. In some cases is no errors (mb transform is not null).

Log Screen
image

Support drawing PolygonCollider2D

Currently this is not supported.

public static void raw(Collider2D collider, Color color, float duration = 0)
{
#if UNITY_EDITOR
switch (collider)
{
case BoxCollider2D boxCollider:
var box = new Shape.Box2D(boxCollider);
box.Draw(s_Builder, color, duration);
if (boxCollider.edgeRadius > 0)
{
float edgeRadius = boxCollider.edgeRadius;
Matrix4x4 matrix = box.Matrix;
Quaternion rotation = matrix.rotation;
Vector3 topRight = matrix.MultiplyPoint3x4(Shape.Box2D.s_Vertices[(int)Shape.Box2D.VertexCorner.TopRight]),
topLeft = matrix.MultiplyPoint3x4(Shape.Box2D.s_Vertices[(int)Shape.Box2D.VertexCorner.TopLeft]),
bottomLeft = matrix.MultiplyPoint3x4(Shape.Box2D.s_Vertices[(int)Shape.Box2D.VertexCorner.BottomLeft]),
bottomRight = matrix.MultiplyPoint3x4(Shape.Box2D.s_Vertices[(int)Shape.Box2D.VertexCorner.BottomRight]);
var angle = Shape.Angle.FromTurns(0.25f);
Quaternion topRightRot = Quaternion.AngleAxis(45, Vector3.forward) * rotation,
topLeftRot = Quaternion.AngleAxis(135, Vector3.forward) * rotation,
bottomLeftRot = Quaternion.AngleAxis(225, Vector3.forward) * rotation,
bottomRightRot = Quaternion.AngleAxis(315, Vector3.forward) * rotation;
new Shape.Arc(topRight, topRightRot, edgeRadius, angle).Draw(s_Builder, color, duration);
new Shape.Arc(topLeft, topLeftRot, edgeRadius, angle).Draw(s_Builder, color, duration);
new Shape.Arc(bottomLeft, bottomLeftRot, edgeRadius, angle).Draw(s_Builder, color, duration);
new Shape.Arc(bottomRight, bottomRightRot, edgeRadius, angle).Draw(s_Builder, color, duration);
float h = Mathf.Sqrt(edgeRadius * edgeRadius * 0.5f);
Vector3 a = new Vector3(h, h, 0),
b = new Vector3(h, -h, 0);
new Shape.Line(topLeft + topLeftRot * b, topRight + topRightRot * a).Draw(s_Builder, color, duration);
new Shape.Line(topRight + topRightRot * b, bottomRight + bottomRightRot * a).Draw(s_Builder, color, duration);
new Shape.Line(bottomRight + bottomRightRot * b, bottomLeft + bottomLeftRot * a).Draw(s_Builder, color, duration);
new Shape.Line(bottomLeft + bottomLeftRot * b, topLeft + topLeftRot * a).Draw(s_Builder, color, duration);
}
break;
case CircleCollider2D circleCollider2D:
new Shape.Circle2D(circleCollider2D).Draw(s_Builder, color, duration);
break;
case CapsuleCollider2D capsuleCollider:
new Shape.Capsule2D(capsuleCollider).Draw(s_Builder, color, duration);
break;
default:
// Could be null
return;
}
#endif
}

Quaternion To Matrix conversion failed

Error 1 Quaternion To Matrix conversion failed because input Quaternion is invalid {-nan(ind), -nan(ind), -nan(ind), -nan(ind)} l=-nan(ind) UnityEngine.Matrix4x4:TRS (UnityEngine.Vector3,UnityEngine.Quaternion,UnityEngine.Vector3) Vertx.Debugging.Shape/Arc:.ctor (UnityEngine.Vector3,UnityEngine.Quaternion,single,Vertx.Debugging.Shape/Angle) (at Library/PackageCache/[email protected]/Runtime/Shapes/Shapes.cs:528) Vertx.Debugging.Shape/Arc:.ctor (UnityEngine.Vector2,single,single,Vertx.Debugging.Shape/Angle) (at Library/PackageCache/[email protected]/Runtime/Shapes/Shapes.cs:533) Vertx.Debugging.Shape/CapsuleCast2D:Draw (Vertx.Debugging.CommandBuilder,UnityEngine.Color,UnityEngine.Color,single) (at Library/PackageCache/[email protected]/Runtime/Shapes/Shapes.Casts.2D.cs:516) Vertx.Debugging.Shape/CapsuleCast2D:Draw (Vertx.Debugging.CommandBuilder,UnityEngine.Color,single) (at Library/PackageCache/[email protected]/Runtime/Shapes/Shapes.Casts.2D.cs:455) Vertx.Debugging.D:raw (Vertx.Debugging.Shape/CapsuleCast2D,single) (at Library/PackageCache/[email protected]/Runtime/Draw.cs:20) Vertx.Debugging.DrawPhysics2D:CapsuleCast (UnityEngine.Vector2,UnityEngine.Vector2,UnityEngine.CapsuleDirection2D,single,UnityEngine.Vector2,single,int) (at Library/PackageCache/[email protected]/Runtime/DrawPhysics2D.cs:613) Entities.Items.Projectiles.Base.Projectile:OnDrawGizmos () (at Assets/Scenes/Game/Scripts/Entities/Items/Projectiles/Base/Projectile.cs:51) UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
Error 2 Quaternion To Matrix conversion failed because input Quaternion is invalid {nan, nan, nan, nan} l=nan UnityEngine.Matrix4x4:TRS (UnityEngine.Vector3,UnityEngine.Quaternion,UnityEngine.Vector3) Vertx.Debugging.Shape/Arc:.ctor (UnityEngine.Vector3,UnityEngine.Quaternion,single,Vertx.Debugging.Shape/Angle) (at Library/PackageCache/[email protected]/Runtime/Shapes/Shapes.cs:528) Vertx.Debugging.Shape/Arc:.ctor (UnityEngine.Vector2,single,single,Vertx.Debugging.Shape/Angle) (at Library/PackageCache/[email protected]/Runtime/Shapes/Shapes.cs:533) Vertx.Debugging.Shape/CapsuleCast2D:Draw (Vertx.Debugging.CommandBuilder,UnityEngine.Color,UnityEngine.Color,single) (at Library/PackageCache/[email protected]/Runtime/Shapes/Shapes.Casts.2D.cs:517) Vertx.Debugging.Shape/CapsuleCast2D:Draw (Vertx.Debugging.CommandBuilder,UnityEngine.Color,single) (at Library/PackageCache/[email protected]/Runtime/Shapes/Shapes.Casts.2D.cs:455) Vertx.Debugging.D:raw (Vertx.Debugging.Shape/CapsuleCast2D,single) (at Library/PackageCache/[email protected]/Runtime/Draw.cs:20) Vertx.Debugging.DrawPhysics2D:CapsuleCast (UnityEngine.Vector2,UnityEngine.Vector2,UnityEngine.CapsuleDirection2D,single,UnityEngine.Vector2,single,int) (at Library/PackageCache/[email protected]/Runtime/DrawPhysics2D.cs:613) Entities.Items.Projectiles.Base.Projectile:OnDrawGizmos () (at Assets/Scenes/Game/Scripts/Entities/Items/Projectiles/Base/Projectile.cs:51) UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
^ Repeating each frame on Unity 2021.3.24f1.

Code in FixedUpdate:

DrawPhysics2D.CapsuleCast(
    origin: Rb2D.position,
    size: RaycastSize, // 1.74, 4.2 for information's sake 
    capsuleDirection: CapsuleDirection2D.Vertical,
    angle: 0f,
    direction: Rb2D.velocity,
    distance: RaycastDistance, // Rb2D.velocity.magnitude * Time.fixedDeltaTime
    layerMask: Layers.Ground); // 1 << 3

GetPosition extension method missing

Hey there,
I went to give this a try so I added it to a new 2020.3 project and received an error that the GetPosition() Extension method did not exist within DebugUtilsMesh.cs.

Line 27

			var unscaledMatrix = Matrix4x4.TRS(localToWorld.GetPosition(), localToWorld.rotation, Vector3.one);

I added the following to the file to fix the issue locally. Not sure where GetPosition was supposed to actually come from?

		private static Vector3 GetPosition(this Matrix4x4 matrix4X4)
		{
			float x = matrix4X4.m03;
			float y = matrix4X4.m13;
			float z = matrix4X4.m23;
			
			if (float.IsNaN(x)) x = 0;
			if (float.IsNaN(y)) y = 0;
			if (float.IsNaN(z)) z = 0;
			
			return new Vector3(x, y, z);
		}

Thanks,
-MH

Feature request: Draw path

Would be nice to have variants of DrawLine and DrawArrowLine for drawing an IEnumerable<Vector3>/Vector3[].

Add via git URL not working

[Package Manager Window] Cannot perform upm operation: Unable to add package [https://github.com/vertxxyz/Vertx.Debugging]:
Package name 'https://github.com/vertxxyz/Vertx.Debugging' is invalid. [InvalidParameter].
UnityEditor.EditorApplication:Internal_CallUpdateFunctions () (at /Users/bokken/build/output/unity/unity/Editor/Mono/EditorApplication.cs:356)

Can't draw anything other than Shape.Text

Hi,
Thanks for building this incredible library.
I'm trying to use it in Unity 2022.3.2f1
Can't draw anything other than Shape.Text
I'm getting this error:

NullReferenceException: Object reference not set to an instance of an object
Vertx.Debugging.CommandBuilder.g__RenderShape|65_1[T] (Vertx.Debugging.AssetsUtility+Asset1[T] mesh, Vertx.Debugging.AssetsUtility+MaterialAsset material, Vertx.Debugging.CommandBuilder+ShapeBuffersWithData1[T] shape, System.Int32 groupCount, Vertx.Debugging.CommandBuilder+<>c__DisplayClass65_0& , Vertx.Debugging.CommandBuilder+<>c__DisplayClass65_1& ) (at Assets/Vertx.Debugging-master/Runtime/CommandBuilder/CommandBuilder.cs:281)
Vertx.Debugging.CommandBuilder.g__RenderShapes|65_0 (Vertx.Debugging.CommandBuilder+<>c__DisplayClass65_0& ) (at Assets/Vertx.Debugging-master/Runtime/CommandBuilder/CommandBuilder.cs:263)
Vertx.Debugging.CommandBuilder.FillCommandBuffer (UnityEngine.Rendering.CommandBuffer commandBuffer, UnityEngine.Camera camera, Vertx.Debugging.CommandBuilder+BufferGroup group, Vertx.Debugging.CommandBuilder+RenderingType renderingType) (at Assets/Vertx.Debugging-master/Runtime/CommandBuilder/CommandBuilder.cs:251)
Vertx.Debugging.CommandBuilder.SharedRenderingDetails (UnityEngine.Camera camera, Vertx.Debugging.CommandBuilder+BufferGroup group, UnityEngine.Rendering.CommandBuffer& commandBuffer, Vertx.Debugging.CommandBuilder+RenderingType renderingType) (at Assets/Vertx.Debugging-master/Runtime/CommandBuilder/CommandBuilder.cs:214)
Vertx.Debugging.CommandBuilder.ExecuteDrawRenderPass (UnityEngine.Rendering.ScriptableRenderContext context, UnityEngine.Rendering.CommandBuffer commandBuffer, UnityEngine.Camera camera) (at Assets/Vertx.Debugging-master/Runtime/CommandBuilder/CommandBuilder.cs:164)
Vertx.Debugging.VertxDebuggingRenderPass.Execute (UnityEngine.Rendering.ScriptableRenderContext context, UnityEngine.Rendering.Universal.RenderingData& renderingData) (at Assets/Vertx.Debugging-master/Runtime/Passes/VertxDebuggingPass.URP.cs:50)
UnityEngine.Rendering.Universal.ScriptableRenderer.ExecuteRenderPass (UnityEngine.Rendering.ScriptableRenderContext context, UnityEngine.Rendering.Universal.ScriptableRenderPass renderPass, UnityEngine.Rendering.Universal.RenderingData& renderingData) (at ./Library/PackageCache/[email protected]/Runtime/ScriptableRenderer.cs:1490)
UnityEngine.Rendering.Universal.ScriptableRenderer.ExecuteBlock (System.Int32 blockIndex, UnityEngine.Rendering.Universal.ScriptableRenderer+RenderBlocks& renderBlocks, UnityEngine.Rendering.ScriptableRenderContext context, UnityEngine.Rendering.Universal.RenderingData& renderingData, System.Boolean submit) (at ./Library/PackageCache/[email protected]/Runtime/ScriptableRenderer.cs:1446)
UnityEngine.Rendering.Universal.ScriptableRenderer.Execute (UnityEngine.Rendering.ScriptableRenderContext context, UnityEngine.Rendering.Universal.RenderingData& renderingData) (at ./Library/PackageCache/[email protected]/Runtime/ScriptableRenderer.cs:1248)
UnityEngine.Rendering.Universal.UniversalRenderPipeline.RenderSingleCamera (UnityEngine.Rendering.ScriptableRenderContext context, UnityEngine.Rendering.Universal.CameraData& cameraData, System.Boolean anyPostProcessingEnabled) (at ./Library/PackageCache/[email protected]/Runtime/UniversalRenderPipeline.cs:650)
UnityEngine.Rendering.Universal.UniversalRenderPipeline.RenderSingleCameraInternal (UnityEngine.Rendering.ScriptableRenderContext context, UnityEngine.Camera camera) (at ./Library/PackageCache/[email protected]/Runtime/UniversalRenderPipeline.cs:534)
UnityEngine.Rendering.Universal.UniversalRenderPipeline.Render (UnityEngine.Rendering.ScriptableRenderContext renderContext, System.Collections.Generic.List1[T] cameras) (at ./Library/PackageCache/[email protected]/Runtime/UniversalRenderPipeline.cs:376) UnityEngine.Rendering.RenderPipeline.InternalRender (UnityEngine.Rendering.ScriptableRenderContext context, System.Collections.Generic.List1[T] cameras) (at :0)
UnityEngine.Rendering.RenderPipelineManager.DoRenderLoop_Internal (UnityEngine.Rendering.RenderPipelineAsset pipe, System.IntPtr loopPtr, UnityEngine.Object renderRequest, Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle safety) (at :0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.