Debug Utility Extension - fallenblood7080/Unity-Extension-Method GitHub Wiki
- Log(string)
- Log (array)
- Log (List)
- DrawPolygon
- VisualizeRay2D
- VisualizeRay
- DrawLineTo
- DrawLineFromPoints
- DrawLineFromPoints (List)
- DrawSphere
Writes a log message to the Unity console with the specified color and font size.
// Example: Log a message with default settings
"Hello, Unity!".Log();
// Example: Log a message with red color and font size 18
"Error!".Log(logColorCode: "ff0000", fontSize: 18);string message = "Hello, Unity!";
message.Log(logColorCode, fontSize);| Parameter | Data Type | Description | 
|---|---|---|
| message | string | The message to be written in the Unity Console. | 
| logColorCode | string | Hex code of the color (default is white - "ffffff"). | 
| fontSize | int | Font size of the message (default is 12). | 
This extension method logs a message to the Unity console with optional color and font size.
Writes the elements of an array to the Unity console with the specified color and font size.
// Example: Log an array of integers with default settings
int[] numbers = { 1, 2, 3, 4, 5 };
numbers.Log();
// Example: Log an array of strings with red color and font size 18
string[] words = { "apple", "banana", "cherry" };
words.Log(logColorCode: "ff0000", fontSize: 18);T[] array = { ... };
array.Log(logColorCode, fontSize);| Parameter | Data Type | Description | 
|---|---|---|
| array | T[] | The array whose elements will be logged. | 
| logColorCode | string | Hex code of the color (default is white - "ffffff"). | 
| fontSize | int | Font size of the message (default is 12). | 
This extension method logs the elements of an array to the Unity console with optional color and font size.
Writes the elements of a List to the Unity console with the specified color and font size.
// Example: Log a List of floats with default settings
List<float> values = new List<float> { 1.0f, 2.5f, 3.7f };
values.Log();
// Example: Log a List of strings with red color and font size 18
List<string> names = new List<string> { "Alice", "Bob", "Charlie" };
names.Log(logColorCode: "ff0000", fontSize: 18);List<T> list = new List<T> { ... };
list.Log(logColorCode, fontSize);| Parameter | Data Type | Description | 
|---|---|---|
| list | List | The List whose elements will be logged. | 
| logColorCode | string | Hex code of the color (default is white - "ffffff"). | 
| fontSize | int | Font size of the message (default is 12). | 
This extension method logs the elements of a List to the Unity console with optional color and font size.
Draws the outline of a polygon in the Unity Scene view.
// Example: Draw a hexagon with a radius of 5 units
Vector3 center = new Vector3(0, 0, 0);
center.DrawPolygon(radius: 5, orientation: Quaternion.identity, color: Color.white, vertices: 6);Vector3 center = new Vector3(x, y, z);
center.DrawPolygon(radius, orientation, color, vertices, dur);| Parameter | Data Type | Description | 
|---|---|---|
| center | Vector3 | Center of the polygon in 3D space. | 
| radius | float | Radius of the polygon, representing the distance from the center to a vertex. | 
| orientation | Quaternion | Orientation of the 2D shape in the world. | 
| color | Color | Color of the outline. | 
| vertices | int | Number of vertices to determine the shape's sides (e.g., 3 for a triangle, 4 for a square). | 
| dur | float | Duration for which the polygon should appear in seconds. | 
This extension method draws the outline of a polygon in the Unity Scene view.
Visualizes a 2D ray by drawing a line from the specified origin to the point where it hits an object.
// Example: Visualize a 2D ray hit with red color
RaycastHit2D rayHit = Physics2D.Raycast(origin, direction);
rayHit.VisualizeRay2D(origin, color: Color.red);RaycastHit2D rayHit = Physics2D.Raycast(origin, direction);
rayHit.VisualizeRay2D(origin, color, dur);| Parameter | Data Type | Description | 
|---|---|---|
| rayHit | RaycastHit2D | The RaycastHit2D result representing the intersection of the ray with an object. | 
| origin | Vector2 | The starting point of the ray in 2D space. | 
| color | Color | Color of the visualization line. | 
| dur | float | Duration for which the visualization line should appear in seconds. | 
This extension method visualizes a 2D ray hit by drawing a line in the Unity Scene view.
Visualizes a 3D ray by drawing a line from the specified origin to the point where it hits an object.
// Example: Visualize a 3D ray hit with green color
RaycastHit rayHit = Physics.Raycast(origin, direction);
rayHit.VisualizeRay(origin, color: Color.green);RaycastHit rayHit = Physics.Raycast(origin, direction);
rayHit.VisualizeRay(origin, color, dur);| Parameter | Data Type | Description | 
|---|---|---|
| rayHit | RaycastHit | The RaycastHit result representing the intersection of the ray with an object. | 
| origin | Vector3 | The starting point of the ray in 3D space. | 
| color | Color | Color of the visualization line. | 
| dur | float | Duration for which the visualization line should appear in seconds. | 
This extension method visualizes a 3D ray hit by drawing a line in the Unity Scene view.
Draws a straight line from the specified origin point to the end point with the given color.
// Example: Draw a line from (0,0,0) to (1,1,1) with blue color
Vector3 origin = new Vector3(0, 0, 0);
Vector3 end = new Vector3(1, 1, 1);
origin.DrawLineTo(end, color: Color.blue);Vector3 origin = new Vector3(x1, y1, z1);
Vector3 end = new Vector3(x2, y2, z2);
origin.DrawLineTo(end, color, dur);| Parameter | Data Type | Description | 
|---|---|---|
| origin | Vector3 | The starting point of the line in 3D space. | 
| end | Vector3 | The ending point of the line in 3D space. | 
| color | Color | Color of the drawn line. | 
| dur | float | Duration for which the line should be visible in seconds. | 
This extension method draws a straight line in the Unity Scene view.
Draws a series of lines connecting the points in the provided array, creating a continuous path.
// Example: Draw a path from an array of points with yellow color
Vector3[] points = { new Vector3(0, 0, 0), new Vector3(1, 1, 1), new Vector3(2, 0, 0) };
points.DrawLineFromPoints(color: Color.yellow);Vector3[] points = { ... };
points.DrawLineFromPoints(color, dur);| Parameter | Data Type | Description | 
|---|---|---|
| points | Vector3[] | An array of Vector3 points representing the path to be drawn. | 
| color | Color | Color of the drawn lines. | 
| dur | float | Duration for which the lines should be visible in seconds. | 
This extension method draws a series of lines connecting points in the Unity Scene view.
Draws a series of lines connecting the points in the provided List, creating a continuous path.
// Example: Draw a path from a List of points with magenta color
List<Vector3> pointsList = new List<Vector3> { new Vector3(0, 0, 0), new Vector3(1, 1, 1), new Vector3(2, 0, 0) };
pointsList.DrawLineFromPoints(color: Color.magenta);List<Vector3> pointsList = new List<Vector3> { ... };
pointsList.DrawLineFromPoints(color, dur);| Parameter | Data Type | Description | 
|---|---|---|
| pointsList | List | A List of Vector3 points representing the path to be drawn. | 
| color | Color | Color of the drawn lines. | 
| dur | float | Duration for which the lines should be visible in seconds. | 
This extension method draws a series of lines connecting points in the Unity Scene view.
Draws a 3D sphere with the specified center, radius, orientation, color, and level of detail (segments).
// Example: Draw a sphere at the origin with a radius of 2 units and red color
Vector3 center = new Vector3(0, 0, 0);
center.DrawSphere(radius: 2, orientation: Quaternion.identity, color: Color.red);Vector3 center = new Vector3(x, y, z);
center.DrawSphere(radius, orientation, color, segments, dur);| Parameter | Data Type | Description | 
|---|---|---|
| center | Vector3 | The center of the sphere in 3D space. | 
| radius | float | The radius of the sphere, determining its size. | 
| orientation | Quaternion | The orientation of the sphere as a Quaternion. | 
| color | Color | The color of the sphere's outline. | 
| segments | int | The number of segments used to approximate the sphere's surface (for smoother rendering). | 
| dur | float | The duration for which the sphere should appear in seconds. | 
This extension method draws a 3D sphere in the Unity Scene view.