Skip to content
This repository was archived by the owner on Sep 26, 2024. It is now read-only.

Commit 702e18c

Browse files
Update license / readme in addons/
1 parent 12aad7c commit 702e18c

File tree

1 file changed

+102
-2
lines changed

1 file changed

+102
-2
lines changed

addons/visualize/README.md

Lines changed: 102 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,102 @@
1-
# Visualize
2-
Effortlessly Debug Script Variables In-Game for Godot 4 C#
1+
https://github.com/user-attachments/assets/a8615166-0a5c-4f8c-a144-7c0f9c5ef185
2+
3+
#### Example Usage
4+
```cs
5+
using Godot;
6+
using System.Collections.Generic;
7+
using Visualize;
8+
9+
public partial class VisualizeExample : Sprite2D
10+
{
11+
[Visualize] Vector2I position;
12+
[Visualize] float rotation;
13+
[Visualize] Color color = Colors.White;
14+
[Visualize] float skew;
15+
16+
private readonly VisualLogger logger = new();
17+
18+
Vector2 initialPositionOffset;
19+
20+
public override void _Ready()
21+
{
22+
initialPositionOffset = DisplayServer.WindowGetSize() / 2;
23+
}
24+
25+
public override void _PhysicsProcess(double delta)
26+
{
27+
Position = position + initialPositionOffset;
28+
Rotation = rotation;
29+
Modulate = color;
30+
Skew = skew;
31+
}
32+
33+
[Visualize]
34+
public void PrintDictionary(Dictionary<int, Vector4> dictionary)
35+
{
36+
if (dictionary == null || dictionary.Count == 0)
37+
{
38+
logger.Log("Method dictionary param has no elements", this);
39+
}
40+
else
41+
{
42+
string logMessage = "[\n";
43+
44+
foreach (KeyValuePair<int, Vector4> kvp in dictionary)
45+
{
46+
logMessage += $" {{ {kvp.Key}, {kvp.Value} }},\n";
47+
}
48+
49+
logMessage = logMessage.TrimEnd('\n', ',') + "\n]";
50+
51+
logger.Log(logMessage, this);
52+
}
53+
}
54+
55+
[Visualize]
56+
public void PrintEnum(SomeEnum someEnum)
57+
{
58+
logger.Log(someEnum, this);
59+
}
60+
61+
public enum SomeEnum
62+
{
63+
One,
64+
Two,
65+
Three
66+
}
67+
}
68+
```
69+
70+
#### Visualizing Info at a Specific Position
71+
72+
You might prefer not to have the visual panel initially created at (0, 0) when visualizing members within a UI node that is always positioned at (0, 0). This can be easily adjusted by adding the `[Visualize(x, y)]` attribute at the top of the class. This attribute will set the initial position of the visual panel to the specified coordinates.
73+
74+
```csharp
75+
[Visualize(200, 200)] // The visual panel will initially be positioned at (200, 200)
76+
public partial class SomeUINode {}
77+
```
78+
79+
#### Supported Members
80+
81+
| Member Type | Supported | Example Types | Additional Notes |
82+
|-------------------|------------|-----------------------------------------------|-----------------------------------------------------------------------|
83+
| **Numericals** || `int`, `float`, `double` | All numerical types are supported |
84+
| **Enums** || `Direction`, `Colors` | All enum types are supported |
85+
| **Booleans** || `bool` | |
86+
| **Strings** || `string` | |
87+
| **Color** || `Color` | |
88+
| **Vectors** || `Vector2`, `Vector2I`, `Vector3`, `Vector3I`, `Vector4`, `Vector4I` | |
89+
| **Quaternion** || `Quaternion` | |
90+
| **NodePath** || `NodePath` | |
91+
| **StringName** || `StringName` | |
92+
| **Methods** || | Method parameters support all listed types here |
93+
| **Static Members**|| | This includes static methods, fields, and properties |
94+
| **Arrays** || `int[]`, `string[]`, `Vector2[]` | Arrays support all listed types here |
95+
| **Lists** || `List<string[]>`, `List<Vector2>` | Lists support all listed types here |
96+
| **Dictionaries** || `Dictionary<List<Color[]>, Vector2>` | Dictionaries support all listed types here |
97+
| **Structs** | ⚠️ | | Appears to work for the most part, needs more testing |
98+
| **Classes** | ⚠️ | | Lots of missing features, things may break if used |
99+
| **Records** || `record` | I couldn't get it to work for some reason |
100+
| **Godot Classes** || `Node`, `PointLight2D` | I'm not even sure how this would work |
101+
102+
By annotating your members with `[Visualize]`, you can streamline the debugging process and gain real-time insights into your game's state and behavior.

0 commit comments

Comments
 (0)