Skip to content

Commit d56e010

Browse files
committed
Add new documentation manuals
1 parent 019ea13 commit d56e010

File tree

8 files changed

+173
-3
lines changed

8 files changed

+173
-3
lines changed

.docfx/manual/benchmarking.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Benchmarking
2+
3+
The Debug Tools package comes with a static class to perform function benchmark tests. The [Benchmark](xref:Zigurous.Debug.Benchmark) class can be used to measure the execution time of a single function or the comparison between multiple functions.
4+
5+
```csharp
6+
// Measures the execution time of Foo over 1000 iterations.
7+
float time = Benchmark.Measure(Foo, 1000);
8+
9+
// Compares the difference in execution time between Foo and Bar over 1000 iterations.
10+
float difference = Benchmark.Compare(Foo, Bar, 1000);
11+
12+
// Performs a benchmark the executes each function 1000 times.
13+
// The time of each function will be logged individually.
14+
// You can pass as many functions as you want.
15+
Benchmark.Run(1000, Foo, Bar, Baz);
16+
```
17+
18+
### Compare Equality
19+
20+
Alternatively, sometimes it is useful to test if the results of two functions are equal. The Debug Tools package comes with another static class [Compare](xref:Zigurous.Debug.Compare`1) to handle these tests. The class uses generics to know the type of value you are looking to compare, and it returns the percentage of results that are equal.
21+
22+
```csharp
23+
Compare<bool>.Test(Foo, Bar, 1000);
24+
Compare<float>.Test(Foo, Bar, 1000);
25+
```

.docfx/manual/framerate.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Framerate Display
2+
3+
The Debug Tools package comes with a script and prefab to display the framerate of the game in realtime. This can be useful if you need to know the framerate outside of the Unity editor.
4+
5+
### Prefab
6+
7+
Simply drag the `FPSDisplay.prefab` into your scene, and you are done! It already comes pre-formatted and is contained within its own UI canvas. You can further customize the display to your liking. By default it is displayed in the top-right corner with zero decimal digits.
8+
9+
### Custom
10+
11+
You can also create your own display if you prefer and add the [FPSDisplay](xref:Zigurous.Debug.FPSDisplay) script to it manually. The script allows you to customize the number of decimal digits to display and how often you want it to refresh. At the minimum, you must pass a reference to a UI Text component that displays the framerate.

.docfx/manual/index.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
# Debug Tools
22

3-
The Debug Tools package contains assets and scripts for debugging Unity projects. Included in the package are scripts for enhanced console logging, comparing performance, displaying framerate, and more.
3+
The Debug Tools package contains assets and scripts for debugging Unity projects. Included in the package are scripts for enhanced console logging, benchmarking, displaying framerate, and more. The package also comes with shaders to visualize different vertex data.
4+
5+
- [Logging](logging.md)
6+
- [Benchmarking](benchmarking.md)
7+
- [Framerate Display](framerate.md)
8+
- [Debug Shaders](shaders.md)

.docfx/manual/logging.md

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Logging
2+
3+
The Debug Tools package provides a static class with more robust logging functions compared to `UnityEngine.Debug`. The [Log](xref:Zigurous.Debug.Log) class can log messages, warnings, and errors to the console. One primary difference is you can log multiple messages through a single function call.
4+
5+
```csharp
6+
Log.Message(a, b, c);
7+
Log.Warning(a, b, c);
8+
Log.Error(a, b, c);
9+
```
10+
11+
You can also provide a custom prefix to display for the message as well as a given context.
12+
13+
```csharp
14+
Log.Message(foo, "[Zigurous]:");
15+
Log.Warning(foo, "[Zigurous]:");
16+
Log.Error(foo, "[Zigurous]:");
17+
18+
Log.Message(foo, context);
19+
Log.Warning(foo, context);
20+
Log.Error(foo, context);
21+
```
22+
23+
### Customization
24+
25+
You can customize the delimiter used when logging multiple messages, and you can set a global prefix that is displayed before each message in order to separate them from others.
26+
27+
```csharp
28+
Log.delimiter = ",";
29+
Log.prefix = "[Zigurous]:";
30+
```
31+
32+
The class also handles null checking to not cause any errors if you log an invalid object. You can even set the string that is displayed when a null reference is logged.
33+
34+
```csharp
35+
Log.nullReference = "Null";
36+
```

.docfx/manual/shaders.md

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Debug Shaders
2+
3+
The Debug Tools package comes with several shaders to visualize different vertex data. These shaders are located under `Zigurous > Debug` within the shader selection menu.
4+
5+
### UV
6+
7+
```hlsl
8+
v2f vert (appdata v)
9+
{
10+
v2f o;
11+
o.pos = UnityObjectToClipPos(v.vertex);
12+
o.uv = float4(v.texcoord.xy, 0, 0);
13+
return o;
14+
}
15+
```
16+
17+
![](https://docs.unity3d.com/uploads/Main/SL-DebugUV1.png)
18+
19+
### Normals
20+
21+
```hlsl
22+
v2f vert (appdata v)
23+
{
24+
v2f o;
25+
o.pos = UnityObjectToClipPos(v.vertex);
26+
o.color.xyz = v.normal * 0.5 + 0.5;
27+
o.color.w = 1.0;
28+
return o;
29+
}
30+
```
31+
32+
![](https://docs.unity3d.com/uploads/Main/SL-DebugNormals.png)
33+
34+
### Tangents
35+
36+
```hlsl
37+
v2f vert (appdata v)
38+
{
39+
v2f o;
40+
o.pos = UnityObjectToClipPos(v.vertex);
41+
o.color = v.tangent * 0.5 + 0.5;
42+
return o;
43+
}
44+
```
45+
46+
![](https://docs.unity3d.com/uploads/Main/SL-DebugTangents.png)
47+
48+
### Bitangents
49+
50+
```hlsl
51+
v2f vert (appdata v)
52+
{
53+
v2f o;
54+
o.pos = UnityObjectToClipPos(v.vertex);
55+
float3 bitangent = cross(v.normal, v.tangent.xyz) * v.tangent.w;
56+
o.color.xyz = bitangent * 0.5 + 0.5;
57+
o.color.w = 1.0;
58+
return o;
59+
}
60+
```
61+
62+
![](https://docs.unity3d.com/uploads/Main/SL-DebugBinormals.png)
63+
64+
### Vertex Color
65+
66+
```hlsl
67+
v2f vert (appdata v)
68+
{
69+
v2f o;
70+
o.pos = UnityObjectToClipPos(v.vertex);
71+
o.color = v.color;
72+
return o;
73+
}
74+
```
75+
76+
![](https://docs.unity3d.com/uploads/Main/SL-DebugColors.png)

.docfx/manual/toc.yml

+10
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,13 @@
22
href: index.md
33
- name: Installation
44
href: installation.md
5+
- name: Reference
6+
items:
7+
- name: Logging
8+
href: logging.md
9+
- name: Benchmarking
10+
href: benchmarking.md
11+
- name: Framerate Display
12+
href: framerate.md
13+
- name: Debug Shaders
14+
href: shaders.md

README.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Debug Tools
22

3-
The Debug Tools package contains assets and scripts for debugging Unity projects. Included in the package are scripts for enhanced console logging, comparing performance, displaying framerate, and more.
3+
The Debug Tools package contains assets and scripts for debugging Unity projects. Included in the package are scripts for enhanced console logging, benchmarking, displaying framerate, and more. The package also comes with shaders to visualize different vertex data.
44

55
## Installation
66

@@ -29,3 +29,10 @@ Import the package namespace in each script or file you want to use it.
2929
```csharp
3030
using Zigurous.Debug;
3131
```
32+
33+
## Reference
34+
35+
- [Logging](https://docs.zigurous.com/com.zigurous.debug/manual/logging.html)
36+
- [Benchmarking](https://docs.zigurous.com/com.zigurous.debug/manual/benchmarking.html)
37+
- [Framerate Display](https://docs.zigurous.com/com.zigurous.debug/manual/framerate.html)
38+
- [Debug Shaders](https://docs.zigurous.com/com.zigurous.debug/manual/shaders.html)

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "com.zigurous.debug",
33
"version": "1.1.0",
44
"displayName": "Zigurous Debug Tools",
5-
"description": "The Debug Tools package contains assets and scripts for debugging Unity projects. Included in the package are scripts for enhanced console logging, comparing performance, displaying framerate, and more.",
5+
"description": "The Debug Tools package contains assets and scripts for debugging Unity projects. Included in the package are scripts for enhanced console logging, benchmarking, displaying framerate, and more. The package also comes with shaders to visualize different vertex data.",
66
"unity": "2019.4",
77
"keywords": [
88
"debug",

0 commit comments

Comments
 (0)