Skip to content

Commit 679de4f

Browse files
committed
Added color support for DebugOverlay.Write and a convenience function for writing buffers
1 parent 3aab773 commit 679de4f

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

Assets/DebugOverlay/DebugOverlay.cs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,14 @@ public static void SetOrigin(float x, float y)
115115
instance.m_OriginY = y;
116116
}
117117

118+
public static void Write(float x, float y, char[] buf, int count)
119+
{
120+
if (instance == null)
121+
return;
122+
for (var i = 0; i < count; i++)
123+
instance.AddQuad(x + i, y, 1, 1, buf[i], instance.m_CurrentColor);
124+
}
125+
118126
public static void Write(float x, float y, string format)
119127
{
120128
if (instance == null)
@@ -198,9 +206,24 @@ public static void DrawLine(float x1, float y1, float x2, float y2, Color col)
198206

199207
void _DrawText(float x, float y, ref char[] text, int length)
200208
{
209+
const string hexes = "0123456789ABCDEF";
210+
Vector4 col = m_CurrentColor;
211+
int xpos = 0;
201212
for (var i = 0; i < length; i++)
202213
{
203-
AddQuad(m_OriginX + x + i, m_OriginY + y, 1, 1, text[i], m_CurrentColor);
214+
if (text[i] == '^' && i < length - 3)
215+
{
216+
var r = hexes.IndexOf(text[i + 1]);
217+
var g = hexes.IndexOf(text[i + 2]);
218+
var b = hexes.IndexOf(text[i + 3]);
219+
col.x = (float)(r * 16 + r) / 255.0f;
220+
col.y = (float)(g * 16 + g) / 255.0f;
221+
col.z = (float)(b * 16 + b) / 255.0f;
222+
i += 3;
223+
continue;
224+
}
225+
AddQuad(m_OriginX + x + xpos, m_OriginY + y, 1, 1, text[i], col);
226+
xpos++;
204227
}
205228
}
206229

0 commit comments

Comments
 (0)